/** * Processes logging in a user. * * @param LoginRequest $request * * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ public function authenticate(LoginRequest $request) { try { $input = $request->all(); $remember = (bool) array_pull($input, 'remember', false); if ($auth = Sentinel::authenticate($input, $remember)) { $message = 'Successfully logged in.'; return redirect()->intended(route('maintenance.dashboard.index'))->withSuccess($message); } else { if (Corp::auth($input['login'], $input['password'])) { $user = Corp::user($input['login']); $name = explode(',', $user->name); $credentials = ['email' => $user->email, 'username' => $user->username, 'password' => $input['password'], 'first_name' => array_key_exists(1, $name) ? $name[1] : null, 'last_name' => array_key_exists(0, $name) ? $name[0] : null]; return $this->registerAndAuthenticateUser($credentials); } } $errors = 'Invalid login or password.'; } catch (NotActivatedException $e) { $errors = 'Account is not activated!'; } catch (ThrottlingException $e) { $delay = $e->getDelay(); $errors = "Your account is blocked for {$delay} second(s)."; } return redirect()->back()->withErrors($errors); }
/** * Display a listing of the resource. * * @return Response */ public function index() { Breadcrumbs::register('portfolio', function ($breadcrumbs) { $breadcrumbs->push('Портфолио', route('portfolio')); }); return view('portfolio.index'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if (false === env('APP_INSTALLED', false)) { return redirect(route('installer.index')); } return $next($request); }
public function store(Request $request) { if (Auth::attempt($request->only('email', 'password'))) { return redirect()->intended(route('admin_path')); } return redirect()->back()->with('errors', 'Wrong email or password'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->check()) { return new RedirectResponse(route('after_login')); } return $next($request); }
/** * create form of a varian * * 1. Get Previous data and page setting * 2. Initialize data * 3. Generate breadcrumb * 4. Generate view * @param q * @return Object View */ public function create($pid = null, $id = null) { //1. Get Previous data and page setting $APIProduct = new APIProduct(); $tmpData = $APIProduct->getShow($pid); //2. Initialize data $data['pid'] = $tmpData['data']['id']; $data['name'] = $tmpData['data']['name']; $data['upc'] = $tmpData['data']['upc']; $data['data'] = null; //is edit if (!is_null($id)) { $data['data'] = $this->VarianFindData($tmpData['data']['varians'], $id)['data']; } //3. Generate breadcrumb if (is_null($id)) { $breadcrumb = [$data['name'] => route('goods.product.show', ['id' => $data['pid']]), 'Ukuran Baru' => route('goods.varian.create', ['pid' => $pid])]; } else { $breadcrumb = [$data['name'] => route('goods.product.show', ['id' => $data['pid']]), 'Edit Ukuran ' . $data['data']['size'] => route('goods.varian.edit', ['pid' => $pid, 'id' => $id])]; } $this->page_attributes->breadcrumb = array_merge($this->page_attributes->breadcrumb, $breadcrumb); //4. Generate view $this->page_attributes->subtitle = $data['name']; $this->page_attributes->data = array_merge($data, ['pid' => $pid]); $this->page_attributes->source = $this->page_attributes->source . 'create'; return $this->generateView(); }
public function update(User $user, UserRequest $request) { $user->update($request->all()); $user->roles()->sync($request->input('roleList')); Flash::success(trans('general.updated_msg')); return redirect(route('admin.users')); }
public static function actionLink($item) { $baseRoute = static::link(Str::lower($item->status)); $param = ['slug' => $item->info->slug]; $url = route($baseRoute, $param); return Gate::allows('mod-qdn', $item->info->slug) ? "<a href='{$url}'>{$item->info->control_id}</a>" : "(is active at the moment)"; }
private function autoDetectUrl($url) { if (strpos($url, '/') != 1 && strpos($url, '://') < 0) { $url = route($url); } return $url; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->check()) { return redirect(route('backend.dashboard')); } return $next($request); }
/** * Muestra la pantalla de bievenida a la red * * @return Response */ public function index() { /* * base_grant_url=https%3A%2F%2Fn126.network-auth.com%2Fsplash%2Fgrant& * user_continue_url=http%3A%2F%2Fenera.mx& * node_id=15269408& * node_mac=00:18:0a:e8:fe:20& * gateway_id=15269408& * client_ip=10.77.147.207& * client_mac=24:a0:74:ed:e6:16 */ // valida que los paramatros esten presentes $validate = Validator::make(Input::all(), ['node_mac' => 'required']); if ($validate->passes()) { $branche = Branche::whereIn('aps', [Input::get('node_mac')])->first(); // Si el AP fue dado de alta y asignado a una Branche if ($branche) { session(['main_bg' => $branche->portal['background']]); $url = route('welcome::response', ['node_mac' => Input::get('node_mac')]); // Paso 1: Welcome log DB::collection('campaign_logs')->where('user.session', session('_token'))->where('device.mac', Input::get('client_mac'))->where('interaction.welcome', 'exists', false)->update(['user' => ['session' => session('_token')], 'device' => ['mac' => Input::get('client_mac')], 'interaction' => ['welcome' => new MongoDate()], 'created_at' => new MongoDate()], array('upsert' => true)); return view('welcome.index', ['image' => $branche->portal['image'], 'message' => $branche->portal['message'], 'login_response' => $this->fbUtils->makeLoginUrl($url)]); } } return view('welcome.invalid', ['main_bg' => 'bg_welcome.jpg']); }
/** * GET | Redirect the user if the 'users' table is empty or not * then redirect it to either login or registration. * * @return mixed */ public function trySampleForms() { if (User::count()) { return redirect()->to(route('showLoginForm'))->withInfo(lang()->get('responses/login.pre_flash_message')); } return redirect()->to(route('showRegistrationForm'))->withInfo(lang()->get('responses/register.pre_flash_message')); }
/** * @return string */ public function getDeleteButtonAttribute() { if (access()->allow('delete-maps')) { return '<a href="' . route('admin.maps.delete', $this->id) . '" class="btn btn-xs btn-danger" data-method="delete"><i class="fa fa-times" data-toggle="tooltip" data-placement="top" title="' . trans('buttons.general.crud.delete') . '"></i></a>'; } return ''; }
/** * Handle the event. * * @param \CachetHQ\Cachet\Events\UserWasInvitedEvent $event * * @return void */ public function handle(UserWasInvitedEvent $event) { $mail = ['email' => $event->invite->email, 'subject' => 'You have been invited.', 'link' => route('signup.invite', ['code' => $event->invite->code]), 'app_url' => env('APP_URL')]; $this->mailer->queue(['html' => 'emails.users.invite-html', 'text' => 'emails.users.invite-text'], $mail, function (Message $message) use($mail) { $message->to($mail['email'])->subject($mail['subject']); }); }
/** * @return \Illuminate\Http\RedirectResponse */ public function postIndex() { // front page accounts $frontPageAccounts = []; if (is_array(Input::get('frontPageAccounts'))) { foreach (Input::get('frontPageAccounts') as $id) { $frontPageAccounts[] = intval($id); } Preferences::set('frontPageAccounts', $frontPageAccounts); } // view range: Preferences::set('viewRange', Input::get('viewRange')); // forget session values: Session::forget('start'); Session::forget('end'); Session::forget('range'); // budget maximum: $budgetMaximum = intval(Input::get('budgetMaximum')); Preferences::set('budgetMaximum', $budgetMaximum); // language: $lang = Input::get('language'); if (in_array($lang, array_keys(Config::get('firefly.languages')))) { Preferences::set('language', $lang); } Session::flash('success', 'Preferences saved!'); Preferences::mark(); return redirect(route('preferences')); }
/** * Display Swagger API page. * * @return \Response */ public function api() { if (config('l5-swagger.generate_always')) { Generator::generateDocs(); } if (config('l5-swagger.proxy')) { $proxy = Request::server('REMOTE_ADDR'); Request::setTrustedProxies([$proxy]); } $extras = []; if (array_key_exists('validatorUrl', config('l5-swagger'))) { // This allows for a null value, since this has potentially // desirable side effects for swagger. See the view for more // details. $extras['validatorUrl'] = config('l5-swagger.validatorUrl'); } // Need the / at the end to avoid CORS errors on Homestead systems. $response = Response::make(view('l5-swagger::index', ['apiKey' => config('l5-swagger.api.auth_token'), 'apiKeyVar' => config('l5-swagger.api.key_var'), 'securityDefinition' => config('l5-swagger.api.security_definition'), 'apiKeyInject' => config('l5-swagger.api.key_inject'), 'secure' => Request::secure(), 'urlToDocs' => route('l5-swagger.docs', config('l5-swagger.paths.docs_json', 'api-docs.json')), 'requestHeaders' => config('l5-swagger.headers.request'), 'docExpansion' => config('l5-swagger.docExpansion'), 'highlightThreshold' => config('l5-swagger.highlightThreshold')], $extras), 200); $headersView = config('l5-swagger.headers.view'); if (is_array($headersView) and !empty($headersView)) { foreach ($headersView as $key => $value) { $response->header($key, $value); } } return $response; }
/** * 메뉴의 링크를 생성하여 반환한다. 메뉴에 link정보가 있을 경우 link정보를 우선 사용하여 생성한다. * 그 다음으로 메뉴에 연결된 route정보를 사용하여 링크를 생성한다. * * @return Route|mixed|string * @throws \Exception */ public function link() { if ($this->display === false) { return '#'; } // menu에 링크 정보가 있을 경우 if ($this->link !== null) { if ($this->link instanceof Closure) { return $this->link(); } else { return $this->link; } } // 어떤 링크정보도 찾을 수 없으면 # if ($this->route === null) { return '#'; } // route 정보 사용 if ($name = $this->route->getName()) { return route($name); } elseif ($action = $this->route->getActionName()) { if ($action !== 'Closure') { return action($action); } } throw new LinkNotFoundException('admin 메뉴가 지정된 route는 name(as)이 지정되어 있거나 Controller action이어야 합니다.'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (is_null($this->auth->user()->household)) { return redirect(route('household.create')); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->check()) { return redirect(route('office_index')); } return $next($request); }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { // LM: 09-02-2015 // See: http://stackoverflow.com/questions/29115184/laravel-catch-tokenmismatchexception if ($e instanceof \Illuminate\Session\TokenMismatchException) { // If the erros is a token mismatch xplog('A token mismatch error happend', __METHOD__); /* @BOOKMARK: TODO For now just log the user out when a token mismatch happens */ return redirect(route('logout')); } // See: https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5 if ($this->isHttpException($e)) { // See: https://laracasts.com/discuss/channels/requests/laravel-5-404-page-driving-me-crazy switch ($e->getStatusCode()) { case '404': return \Response::view('errors.custom.404'); break; /* case '500': return \Response::view('errors.custom.500'); break; */ /* case '500': return \Response::view('errors.custom.500'); break; */ default: return $this->renderHttpException($e); break; } } if (config('app.debug')) { return $this->renderExceptionWithWhoops($e); } return parent::render($request, $e); }
public function testInvalidIdsInProfileOrder() { $newOrder = ['me', 'recent_activities', 'kudosu', 'top_ranks', 'beatmaps', 'medals', 'historical', 'performance']; $newOrderWithInvalid = $newOrder; $newOrderWithInvalid[] = 'test'; $this->actingAs($this->user)->withSession(['verified' => UserVerification::VERIFIED])->json('PUT', route('account.update'), ['order' => $newOrderWithInvalid])->seeJson(['profileOrder' => $newOrder]); }
protected function common($route, array $input = [], $marker = 'REPORT-RESULTS-MARKER') { $user = $this->getSuperUser(); $page = route($route); $button = _('Submit'); $this->actingAs($user)->visit($page)->submitForm($button, $input)->seePageIs($page)->assertSessionHasNoErrors($route)->see($marker); }
/** * Connect the current user to Last.fm. * * @param Redirector $redirector * @param Lastfm $lastfm * * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse */ public function connect(Redirector $redirector, Lastfm $lastfm) { if (!$lastfm->enabled()) { abort(401, 'Koel is not configured to use with Last.fm yet.'); } return $redirector->to('https://www.last.fm/api/auth/?api_key=' . $lastfm->getKey() . '&cb=' . route('lastfm.callback')); }
public function index(Request $request) { $menus = app('menu')->where('parentid', '=', 0)->get(); $leftMainUrl = url('/dash/left_main?menuid='); $params = ['menus' => $menus, 'left_main_url' => $leftMainUrl, 'crumb_url' => route('dash.crumbs')]; return view('dash.index', $params); }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if ($e instanceof ModelNotFoundException || $e instanceof NotFoundHttpException) { return redirect(route('dashboard')); } return parent::render($request, $e); }
/** * @return $this */ public function index() { $this->breadcrumb->push('Moje konto', route('user.home')); $this->breadcrumb->push('Umiejętności', route('user.skills')); $skills = User\Skill::where('user_id', auth()->user()->id)->orderBy('order')->get(); return parent::view('user.skills.home')->with('skills', $skills); }
/** * Returns the initial HTML view for the admin interface. * * @param \Illuminate\Http\Request $request Laravel request object * @return \Illuminate\Contracts\View\View View for rendering the output */ public function indexAction(Request $request) { if (config('shop.authorize', true)) { $this->authorize('admin'); } $site = Route::input('site', 'default'); $lang = Input::get('lang', config('app.locale', 'en')); $aimeos = app('\\Aimeos\\Shop\\Base\\Aimeos')->get(); $cntlPaths = $aimeos->getCustomPaths('controller/extjs'); $context = app('\\Aimeos\\Shop\\Base\\Context')->get(false); $context = $this->setLocale($context, $site, $lang); $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths); $cssFiles = array(); foreach ($aimeos->getCustomPaths('admin/extjs') as $base => $paths) { foreach ($paths as $path) { $jsbAbsPath = $base . '/' . $path; if (!is_file($jsbAbsPath)) { throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath)); } $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path)); $cssFiles = array_merge($cssFiles, $jsb2->getUrls('css')); } } $jqadmUrl = route('aimeos_shop_jqadm_search', array('site' => $site, 'resource' => 'product')); $jsonUrl = route('aimeos_shop_extadm_json', array('site' => $site, '_token' => csrf_token())); $adminUrl = route('aimeos_shop_extadm', array('site' => '<site>', 'lang' => '<lang>', 'tab' => '<tab>')); $vars = array('lang' => $lang, 'cssFiles' => $cssFiles, 'languages' => $this->getJsonLanguages($context), 'config' => $this->getJsonClientConfig($context), 'site' => $this->getJsonSiteItem($context, $site), 'i18nContent' => $this->getJsonClientI18n($aimeos->getI18nPaths(), $lang), 'searchSchemas' => $controller->getJsonSearchSchemas(), 'itemSchemas' => $controller->getJsonItemSchemas(), 'smd' => $controller->getJsonSmd($jsonUrl), 'urlTemplate' => str_replace(['<', '>'], ['{', '}'], urldecode($adminUrl)), 'uploaddir' => config('shop::uploaddir'), 'activeTab' => Input::get('tab', 0), 'version' => $this->getVersion(), 'jqadmurl' => $jqadmUrl); return View::make('shop::admin.extadm-index', $vars); }
/** * Get the post register redirect path if user must verify account. * * @return string */ public function verificationRedirectPath() { if (property_exists($this, 'verificationRedirectPath')) { return $this->verificationRedirectPath; } return property_exists($this, 'verificationRedirectTo') ? $this->verificationRedirectTo : route('verification.verify', [], false); }
function testVerify() { // Given $this->startSession(); $userData = ['name' => 'Some name', 'email' => '*****@*****.**', 'password' => 'strongpassword', 'country_code' => '1', 'phone_number' => '5558180101']; $user = new User($userData); $user->authy_id = 'authy_id'; $user->save(); $this->be($user); $mockAuthyApi = Mockery::mock('Authy\\AuthyApi')->makePartial(); $mockVerification = Mockery::mock(); $mockTwilioClient = Mockery::mock(\Twilio\Rest\Client::class)->makePartial(); $mockTwilioClient->messages = Mockery::mock(); $twilioNumber = config('services.twilio')['number']; $mockTwilioClient->messages->shouldReceive('create')->with($user->fullNumber(), ['body' => 'You did it! Signup complete :)', 'from' => $twilioNumber])->once(); $mockAuthyApi->shouldReceive('verifyToken')->with($user->authy_id, 'authy_token')->once()->andReturn($mockVerification); $mockVerification->shouldReceive('ok')->once()->andReturn(true); $this->app->instance(\Twilio\Rest\Client::class, $mockTwilioClient); $this->app->instance('Authy\\AuthyApi', $mockAuthyApi); $modifiedUser = User::first(); $this->assertFalse($modifiedUser->verified); // When $response = $this->call('POST', route('user-verify'), ['token' => 'authy_token', '_token' => csrf_token()]); // Then $modifiedUser = User::first(); $this->assertRedirectedToRoute('user-index'); $this->assertTrue($modifiedUser->verified); }
/** * Update the settings in storage. * * @param Setting $setting * @param SettingRequest $request * @return Response */ public function patchSettings(Setting $setting, SettingRequest $request) { $data = $this->storeImage($request, 'logo'); $setting->fill($data); $setting->save() == true ? Flash::success(trans('admin.update.success')) : Flash::error(trans('admin.update.fail')); return redirect(route('admin.setting.index')); }