public function filter(Route $route, Request $request) { if ($this->auth->check()) { $config = $this->config->get('c::redirect-login'); $url = $config ? $this->url->to($config) : '/'; return $this->redirect->to($url); } }
/** * Store a newly created resource in storage. * * @param OrderRequest $request * @return \Illuminate\Http\Response */ public function store(OrderRequest $request) { $order = $this->user->createOrder(['status' => 0] + $request->all()); $order->load('statusHistory'); $order->assignNearestDriver(); return $this->jsonRespond->respondModelStore($this->orderTransformer, $order); }
/** * DriversController constructor. * @param AuthManager $auth * @param User $users * @param JsonRespond $jsonRespond * @param UserTransformer $userTransformer */ public function __construct(AuthManager $auth, User $users, JsonRespond $jsonRespond, UserTransformer $userTransformer) { $this->user = $auth->user(); $this->userTransformer = $userTransformer; $this->users = $users; parent::__construct($jsonRespond); }
/** * Handle an incoming request * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->guard()->check()) { return $this->redirect->route('admin', $this->app->getLocale()); } return $next($request); }
/** * Authenticate request. * * @return bool|exception */ public function auth() { if (!$this->auth->attempt($this->getCredentials())) { throw new InvalidBasicAuthCredentials(); } return true; }
/** * @param $request * @param callable $next * @return mixed */ public function handle($request, \Closure $next) { if ($this->auth->check()) { $this->app->setLocale($this->auth->user()->getLocale()); } return $next($request); }
/** * Returns whether the logged in user is allowed to edit a page. * * @return bool */ public function allowedToEdit(Page $page = null) { if ($page === null) { return true; } return Editor::isEnabled() && $this->auth->check('edit', $page); }
public function getIndex() { $user = $this->auth->user(); $threads = $this->threadRepository->getRecentByMember($user); $replies = $this->replyRepository->getRecentByMember($user); $this->render('dashboard.index', compact('user', 'threads', 'replies')); }
public function __construct(AuthManager $auth, OrderTransformer $orderTransformer, JsonRespond $jsonRespond) { parent::__construct($jsonRespond); $this->user = $auth->user(); $this->orderTransformer = $orderTransformer; $this->jsonRespond = $jsonRespond; }
public function postFork($hash) { $parent = $this->repository->getByHash($hash); $command = new Commands\CreateForkCommand($this->request->get('code'), $this->auth->user(), $parent); $fork = $this->bus->execute($command); return $this->redirector->action('BinController@getShow', [$fork->hash]); }
/** * Authenticate request with Basic. * * @param \Illuminate\Http\Request $request * @param \Illuminate\Routing\Route $route * * @return mixed */ public function authenticate(Request $request, Route $route) { $this->validateAuthorizationHeader($request); if ($user = $this->auth->getUser()) { return $user; } throw new UnauthorizedHttpException(null, 'Please log in before perform this query.'); }
/** * Get User * * @return \Illuminate\Contracts\Auth\Authenticatable */ protected function getUser() { if (!$this->user) { $authGuard = $this->config->get('nwlaravel.activity.auth_guard') ?: $this->auth->getDefaultDriver(); $this->user = $this->auth->guard($authGuard)->user(); } return $this->user; }
/** * @param array $data * @return \HorseStories\Models\Events\Event */ public function create($data = []) { $event = new Event(); $event->name = $data['event_name']; $event->creator_id = $this->auth->user()->id; $event->save(); return $event; }
/** * composing the view * * @param \Illuminate\View\View $view */ public function compose(\Illuminate\View\View $view) { $notifications = []; if (null !== ($user = $this->authManager->user())) { $notifications = $this->notificationManager->getForUser($user, [NotificationActivity::CREATED, NotificationActivity::READ]); } $view->with('notifications', $notifications); }
/** * Authenticate request with Basic. * * @param \Illuminate\Http\Request $request * @param \Illuminate\Routing\Route $route * @return mixed */ public function authenticate(Request $request, Route $route) { $this->validateAuthorizationHeader($request); if ($response = $this->auth->onceBasic($this->identifier) and $response->getStatusCode() === 401) { throw new UnauthorizedHttpException('Basic', 'Invalid authentication credentials.'); } return $this->auth->user(); }
public function postDelete($replyId) { $reply = $this->replies->requireById($replyId); $thread = $reply->thread; $command = new Commands\DeleteReplyCommand($reply, $this->auth->user()); $reply = $this->bus->execute($command); return $this->redirector->action('ForumController@getViewThread', [$thread->slug]); }
/** * Get the prepared validation rules. * * @return array */ protected function getPreparedRules() { $forbidden = implode(',', $this->config->get('config.forbidden_usernames', [])); $userId = $this->auth->user()->id; $this->rules['username'] .= '|not_in:' . $forbidden; $this->rules['username'] .= '|unique:users,username,' . $userId; return $this->rules; }
/** * @{inheritDoc} */ public function collect() { try { $user = $this->auth->user(); } catch (\Exception $e) { $user = null; } return $this->getUserInformation($user); }
/** * @param \HorseStories\Models\Statuses\Status $status * @param string $body * @return \HorseStories\Models\Comments\Comment */ public function create(Status $status, $body) { $comment = new Comment(); $comment->status_id = $status->id; $comment->body = $body; $comment->user_id = $this->auth->user()->id; $comment->save(); return $comment; }
/** * Confirm user with token. * * @param string $token * @return Response */ public function index($token) { $user = $this->userRepo->getByConfirmationToken($token); if (!$user) { return view('auth.confirm')->withBadToken(true); } $user->confirm(); $this->auth->login($user); return redirect('/'); }
/** * Handle the command * * @param $command * @throws InvalidCredentialsException * @return mixed */ public function handle($command) { foreach ($this->availableIdentifiers() as $identifier) { $attemptable = [$identifier => $command->identifier, 'password' => $command->password]; if ($this->authManager->attempt($attemptable, $command->remember)) { return true; } } $this->throwError(); }
public function postIndex(Auth $auth, Request $request) { $email = SettingsFacade::get('site.support.email'); $person = $auth->user(); if (!$email) { return; } Mail::send('boomcms::email.support', ['request' => $request, 'person' => $person], function (Message $message) use($email, $person, $request) { $message->to($email)->from($email, SettingsFacade::get('site.name'))->replyTo($person->getEmail())->subject($request->input('subject')); }); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle(Request $request, Closure $next) { $asset = $request->route()->getParameter('asset'); if ($asset && !$this->auth->check()) { $ip = ip2long($request->ip()); if (!AssetDownload::recentlyLogged($asset->getId(), $ip)->count() > 0) { AssetDownload::create(['asset_id' => $asset->getId(), 'ip' => $ip, 'time' => time()]); $asset->incrementDownloads(); } } return $next($request); }
public function filter(Route $route, Request $request) { /** @var \anlutro\Core\Auth\Users\UserModel $user */ if (!($user = $this->auth->user())) { throw new \RuntimeException('auth filter must precede access filter'); } // get an array of function arguments #3 and up $params = array_slice(func_get_args(), 2); foreach ($params as $access) { if (!$user->hasAccess($access)) { return $this->makeResponse($request); } } }
/** * Returns whether the given item should be visible to the user. * * @param array $item * @return bool */ protected function maySeeItem(array $item) { if (!isset($item['logged_in'])) { return true; } return $item['logged_in'] && $this->auth->check(); }
/** * Handle the command. * * @param $command * * @throws \Tectonic\Shift\Modules\Authentication\Exceptions\TokenNotFoundException * @return mixed */ public function handle($command) { // 1. Get token record $token = $this->tokenRepository->getByToken($command->token); // 2. If token record does NOT exist, throw exception if (!$token) { throw new TokenNotFoundException(); } // 3. Authenticate user $data = $this->getTokenData($token); $authUser = $this->auth->loginUsingId($data->userId); // 4. Delete token record $this->tokenRepository->delete($token); // 5. Return authenticated user return $authUser; }
/** * Call a custom driver creator. * @param string $driver * @return \Kbwebs\MultiAuth\Guard */ protected function callCustomCreator($driver) { $custom = parent::callCustomCreator($driver); if ($custom instanceof Guard) { return $custom; } return new Guard($custom, $this->app['session.store'], $this->name); }
/** * Check if a route has role control enabled(via filter) * If the route has role control enabled we check against * the provided user * * @param \Illuminate\Database\Query\Builder $query * @return boolean */ protected function validateRouteUser($query) { if ($this->hasRoleControl($query)) { if ($this->auth->guest() || !$this->checkRouteAgainstUser($query)) { return false; } } return true; }
/** * 임시 데이터 저장 * * @param string $key 구분할 수 있는 키(중복가능) * @param mixed $val 저장될 내용 * @param array $etc 기타 값들 * @param bool $isAuto 자동 저장 인지 여부 * @return TemporaryEntity */ public function set($key, $val, array $etc = [], $isAuto = false) { if ($this->auth->guest()) { return null; } $temporary = new TemporaryEntity(); $temporary->fill(['userId' => $this->auth->user()->getId(), 'key' => $key, 'val' => $val, 'etc' => serialize($etc), 'isAuto' => $isAuto ? 1 : 0]); return $this->repo->insert($temporary); }
/** * @param \Illuminate\Database\Eloquent\Model|int|string $modelOrId * * @throws \Spatie\Activitylog\Exceptions\CouldNotLogActivity * * @return \Illuminate\Database\Eloquent\Model */ protected function normalizeCauser($modelOrId) : Model { if ($modelOrId instanceof Model) { return $modelOrId; } if ($model = $this->auth->getProvider()->retrieveById($modelOrId)) { return $model; } throw CouldNotLogActivity::couldNotDetermineUser($modelOrId); }