/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, \Closure $next) { if ($this->userService->isSignedIn()) { return redirect()->action('User\\IndexController@index'); } return $next($request); }
public function __construct(UserService $userService) { $this->columnModel = array(array('label' => 'ID', 'width' => 100, 'table' => 'user', 'id' => 'id', 'queryParamField' => true), array('label' => 'First Name', 'width' => 100, 'table' => 'user', 'id' => 'first_name', 'edittype' => 'text', 'editable' => true, 'queryParamField' => true), array('label' => 'Last Name', 'width' => 100, 'table' => 'user', 'id' => 'last_name', 'edittype' => 'text', 'editable' => true, 'queryParamField' => true), array('label' => 'Email', 'width' => 100, 'table' => 'user', 'id' => 'email', 'edittype' => 'text', 'editable' => true, 'queryParamField' => true), array('label' => 'Company Name', 'width' => 100, 'table' => 'user', 'id' => 'company_name', 'edittype' => 'text', 'editable' => true, 'queryParamField' => true), array('label' => 'Is Admin', 'width' => 100, 'table' => 'user', 'id' => 'is_admin', 'editable' => true, 'edittype' => 'checkbox', 'editvalues' => '1:0'), array('label' => 'Campaigns', 'width' => 400, 'table' => 'campaign', 'id' => 'campaigns', 'alias' => 'campaigns', 'editable' => true, 'edittype' => 'multiselect', 'editvalues' => $userService->getSpotCampaignIdsForSelectFilter()), array('label' => 'Reports', 'width' => 400, 'table' => 'section', 'id' => 'sections', 'alias' => 'sections', 'editable' => true, 'edittype' => 'multiselect', 'editvalues' => $userService->getSections()), array('label' => 'Fields', 'width' => 400, 'table' => 'scolumn', 'id' => 'scolumns', 'alias' => 'scolumns', 'editable' => true, 'edittype' => 'multiselect', 'editvalues' => $userService->getSColumns()), array('label' => 'Api Key', 'width' => 300, 'table' => 'api_keys', 'id' => 'key', 'edittype' => 'text', 'editable' => true, 'queryParamField' => true), array('label' => 'Allowed IP Range', 'width' => 300, 'table' => 'user', 'id' => 'allowed_ip_range', 'edittype' => 'text', 'editable' => true)); $this->url = route('user-api'); $this->connectionName = 'ott'; $this->customNavButtons = array('deleteRow', 'exportCsv', 'changePassword', 'createApiKey'); parent::__construct($userService); $this->grid->setSortName('id')->setMultiselect(true)->setSortOrder('DESC')->setInlineNavOptions(['addParams' => ['position' => "last", 'restoreAfterError' => false, 'addRowParams' => ['successfunc' => new Expr(' function(response){ if(response.responseJSON.success){ toastr.success("User updated"); jQuery("' . $this->grid->getGridIdentifier() . '").trigger("reloadGrid"); } else { jQuery.each(jQuery.parseJSON(response.responseJSON.message), function( index, value ) { toastr.error(value); }); return false; } } ')]], 'editParams' => ['restoreAfterError' => false, 'successfunc' => new Expr(' function(response){ if(response.responseJSON.success){ toastr.success("User updated"); jQuery("' . $this->grid->getGridIdentifier() . '").trigger("reloadGrid"); } else { jQuery.each(jQuery.parseJSON(response.responseJSON.message), function( index, value ) { toastr.error(value); }); return false; } } ')]])->setEditUrl($this->url); }
/** * @param UserRegisterRequest $request * @param UserService $user * @return \Illuminate\Http\RedirectResponse */ public function postRegister(UserRegisterRequest $request, UserService $user) { $input = $request->only(['name', 'email', 'password']); $result = $user->registerUser($input); $this->auth->login($result); return redirect()->route('admin.entry.index'); }
/** * Returns data about user * * @param $id * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function view($id, Request $request) { // only profile owner can see data if ($request->user()->id !== (int) $id) { abort(403); } return response()->json($this->userService->getUserProfileData($id)); }
/** * @dataProvider userDataProvider */ public function testGetUserProfileData($id, $userData, $expectedData) { $userStorageMock = $this->getMock('\\App\\Contracts\\Storages\\UserStorageContract'); $userStorageMock->expects(static::any())->method('getUserData')->with($id)->willReturn($userData); $itemStorageMock = $this->getMock('\\App\\Contracts\\Storages\\ItemStorageContract', ['getCategoriesItems']); $userService = new UserService($userStorageMock, $itemStorageMock); $data = $userService->getUserProfileData($id); static::assertEquals($expectedData, $data); }
/** * Sign up the user:user /base/test/demo * Sign up the admin:admin /base/test/demo/admin */ public function demoAction() { $username = $this->dispatcher->getParam('param', null, 'user'); $user = new UserService(); // Skip rules $user->setRules([], false); $create = $user->signup(['username' => $username, 'password' => $username, 'repeatPassword' => $username, 'email' => $username . '@example.com', 'repeatEmail' => $username . '@example.com']); $activation = $user->addRole(); $this->view->setContent($this->dump->vars($create, $activation)); }
public function __construct(UserService $userService) { $this->columnModel = array(array('label' => 'Country', 'width' => 200, 'table' => 'country', 'alias' => 'country', 'id' => 'name', 'defaultValue' => null, 'searchType' => 'select', 'svalues' => $userService->getCountryListForSelectFilter()), array('label' => 'Leads', 'width' => 200, 'table' => 'clients', 'type' => 'raw', 'alias' => 'leads', 'rawValue' => 'COUNT(clients.id)', 'id' => 'lead'), array('label' => 'Customers', 'width' => 200, 'table' => 'clients', 'type' => 'raw', 'alias' => 'customers', 'rawValue' => 'COUNT(clients.id) - SUM(clients.islead)', 'id' => 'customers'), array('label' => 'Deposits Count', 'width' => 200, 'table' => 'deposits', 'type' => 'raw', 'alias' => 'dcount', 'rawValue' => 'COALESCE(deposits.dcount, 0)', 'id' => 'dcount'), array('label' => 'Deposits Amount', 'width' => 200, 'table' => 'deposits', 'type' => 'raw', 'alias' => 'damount', 'rawValue' => 'COALESCE(deposits.damount, 0)', 'id' => 'damount'), array('label' => 'FTD', 'width' => 200, 'table' => 'deposits', 'type' => 'raw', 'alias' => 'FTD', 'rawValue' => 'COALESCE(deposits.FTD, 0)', 'id' => 'FTD')); $this->rawQueryParamFields = array(array('field' => 'campaigns', 'type' => 'multiselect', 'sort' => false, 'queryOp' => 'inclusive', 'dbField' => 'customers.campaignId'), array('field' => 'country', 'type' => 'multiselect', 'sort' => true, 'queryOp' => 'inclusive', 'dbField' => 'customers.Country'), array('field' => 'dateRange', 'type' => 'dateRange', 'defaultValue' => Json::encode(array('start' => date(Config::get('app.dateformat')), 'end' => date(Config::get('app.dateformat')))), 'sort' => false)); $this->url = route('country-api'); $this->connectionName = 'so_rep'; $this->sortname = 'damount'; $this->postDataFields = array('campaigns' => new Expr("jQuery('#'+'%field%').val();"), 'dateRange' => new Expr("JSON.stringify(\$('#'+'%field%').daterangepicker('getRange'));")); $this->customNavButtons = array('exportCsv'); parent::__construct($userService); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!$this->userService->isSignedIn()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect()->guest(\URL::action('User\\AuthController@getSignIn')); } } view()->share('authUser', $this->userService->getUser()); return $next($request); }
public function testUserRegister() { $path = base_path('tests/storage/logs/user_register.log'); \Log::useFiles($path); $user = $this->service->registerUser([]); $this->assertFileExists($path); $content = file_get_contents($path); $this->assertNotFalse(strpos($content, '*****@*****.**')); $this->assertNotFalse(strpos($content, 'ユーザー登録が完了しました')); $this->assertNotFalse(strpos($content, 'testing')); $this->beforeApplicationDestroyed(function () use($path) { \File::delete($path); }); }
public function __construct(UserService $userService, CampaignService $campaignService) { $this->columnModel = array(array('label' => 'Campaigns', 'width' => 300, 'table' => 'campaign', 'id' => 'name', 'alias' => 'campaigns', 'searchType' => 'select', 'svalues' => $userService->getCampaignListForSelectFilter()), array('label' => 'Country', 'width' => 300, 'table' => 'campaign_country', 'id' => 'id', 'alias' => 'country', 'searchType' => 'select', 'svalues' => $userService->getCountryListForMultiSelectFilter(), 'editable' => true, 'edittype' => 'multiselect', 'editvalues' => $userService->getCountryIdsForSelectFilter()), array('label' => 'Platform', 'width' => 300, 'table' => 'campaign_platform', 'alias' => 'platforms', 'id' => 'platform_id', 'searchType' => 'select', 'svalues' => $userService->getPlatformListForSelectFilter(), 'editable' => true, 'edittype' => 'multifind', 'editvalues' => $userService->getPlatformIdsForSelectFilter(), 'multiple' => false, 'type' => 'select')); $this->rawQueryParamFields = array(array('field' => 'campaigns', 'type' => 'multiselect', 'sort' => false, 'queryOp' => 'inclusive', 'dbField' => 'campaign.id'), array('field' => 'country', 'type' => 'multiselect', 'sort' => false, 'queryOp' => 'inclusive', 'dbField' => 'campaign_country.country_id'), array('field' => 'platforms', 'type' => 'multiselect', 'sort' => false, 'queryOp' => 'inclusive', 'dbField' => 'campaign_platform.platform_id')); $this->url = route('campaign-api'); $this->connectionName = 'ott'; $this->customNavButtons = array('exportCsv'); parent::__construct($userService); $this->grid->setSortName('id')->setMultiselect(true)->setSortOrder('ASC')->setInlineNavOptions(['editParams' => ['restoreAfterError' => false, 'successfunc' => new Expr(' function(response){ if(response.responseJSON.success){ toastr.success("Campaign updated"); jQuery("' . $this->grid->getGridIdentifier() . '").trigger("reloadGrid"); } else { jQuery.each(jQuery.parseJSON(response.responseJSON.message), function( index, value ) { toastr.error(value); }); return false; } } ')]])->setEditUrl($this->url); }
public function testGetUserRepository() { $this->assertInstanceOf(Collection::class, $this->service->getUsers()); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $data = UserService::destroy($id); return response()->json($data); }
/** * Test UserServiceContract::deleteUser(User $user). * * @return void */ public function testDeleteUser() { $mockUser = $this->getMockUser(); $mockRepository = $this->getMockUserRepository(); $mockRepository->shouldReceive('delete')->once()->with($mockUser)->andReturn(true); $service = new UserService($mockRepository); $result = $service->deleteUser($mockUser); $this->assertEquals($result, true, 'deleteUser(User $user) returned an invalid result'); }
<?php use app\services\OauthWeixinUserService; use app\extensions\util\HttpUserAgentUtil; use lithium\action\Response; use app\services\UserService; use lithium\net\http\Router; use lithium\action\Dispatcher; /** * 拦截登录过滤器, 检测页面访问权限. */ Dispatcher::applyFilter('run', function ($self, $params, $chain) { $router = Router::parse($params['request']); if (empty($router->params)) { return $chain->next($self, $params, $chain); } else { $router = $router->params; } if (UserService::check_auth($router)) { // 如果是微信里的页面, 则需要注入当前的微信用户信息 if (HttpUserAgentUtil::is_weixin()) { OauthWeixinUserService::set_current_oauth_user(); } return $chain->next($self, $params, $chain); } else { $login_url = SYS_PATH . '/user/login?ref_url=' . urldecode(current_url()); return new Response(array('location' => $login_url)); } });
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, \Closure $next) { $user = $this->userService->getUser(); \View::share('authUser', $user); return $next($request); }
/** * @param UserRegisterRequest $request * @param UserService $user * * @return \Illuminate\Http\RedirectResponse */ public function postRegister(UserRegisterRequest $request, UserService $user) { $result = $user->registerUser($request->only(['name', 'email', 'password'])); $this->auth->login($result); return redirect()->route('admin.entry.index')->with('register_message', trans('message.register.success')); }