/** * @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); }
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]); }
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')); }
/** * 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(); }
/** * 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); }
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]); }
/** * @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; }
/** * 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; }
/** * @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; }
/** * @{inheritDoc} */ public function collect() { try { $user = $this->auth->user(); } catch (\Exception $e) { $user = null; } return $this->getUserInformation($user); }
/** * Create an instance of the Manager * * @param \Illuminate\Routing\Router $router * @param \Illuminate\Database\DatabaseManager $db * @param \Illuminate\Auth\AuthManager $auth * @param \Illuminate\Config\repository $config * @return void */ public function __construct(Router $router, IlluminateDatabaseManager $db, AuthManager $auth, Repository $config) { $this->db = $db; $this->router = $router; $this->auth = $auth; $this->config = $config; // Set the user object $this->user = $this->auth->user(); // Set the role control identifier from config $this->roleControlIdentifier = $this->config->get('role::role.control.identifier'); }
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); } } }
/** * Log in the user. * * @return \Response */ public function store() { $input = Input::only('email', 'password'); $remember = Input::has('remember'); $this->logInForm->validate($input); if (!$this->auth->once($input)) { return json(['errors' => trans('errors.credentials')]); } if (!$this->auth->user()->confirmed) { return json(['errors' => trans('errors.not_confirmed')]); } $this->auth->login($this->auth->user(), $remember); return json(true); }
public function __construct(DriverLocationTransformer $driverLocationTransformer, AuthManager $authManager, JsonRespond $jsonRespond) { parent::__construct($jsonRespond); $this->user = $authManager->user(); $this->jsonRespond = $jsonRespond; $this->driverLocationTransformer = $driverLocationTransformer; }
/** * 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); }
public function __construct(AuthManager $auth, OrderTransformer $orderTransformer, JsonRespond $jsonRespond) { parent::__construct($jsonRespond); $this->user = $auth->user(); $this->orderTransformer = $orderTransformer; $this->jsonRespond = $jsonRespond; }
/** * 임시 데이터 저장 * * @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); }
public function login() { if ($this->auth->check() && $this->auth->user()->can(['Dashboard'])) { return $this->redirector->route("dashboard"); } if ($this->auth->check() && !$this->auth->user()->can(['Dashboard'])) { return $this->redirector->route("home"); } $url = $this->request->get("url"); return $this->theme->baseDashboard("Admin::login")->with("url", $url); }
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')); }); }
/** * Initializes the Guardian instance. * * @return void */ protected function init() { $user = $this->auth->user(); if (is_null($user)) { return $this->loggedIn = false; } else { if (!$user instanceof AccessControlInterface) { throw new InvalidUserInstanceException('User Model Should Implement Usman\\Guardian\\AccessControl\\AccessControlInterface'); } $this->user = $user; $this->loggedIn = true; } }
/** * @param array $values * @param bool $pedigree * @return \HorseStories\Models\Horses\Horse */ public function create($values = [], $pedigree = false) { $horse = new Horse(); $horse->name = $values['name']; if (!$pedigree) { $horse->user_id = $this->auth->user()->id; } $horse->gender = $values['gender']; $horse->breed = $values['breed']; $horse->life_number = $values['life_number']; $horse->color = $values['color']; $horse->date_of_birth = DateTime::createFromFormat('d/m/Y', $values['date_of_birth']); $horse->height = $values['height']; $horse->slug = $this->slugCreator->createForHorse($values['name']); $horse->save(); if (array_key_exists('disciplines', $values)) { foreach ($values['disciplines'] as $discipline) { $horse->disciplines()->updateOrCreate(['discipline' => $discipline, 'horse_id' => $horse->id]); } } return $horse; }
public function edit($id) { $user = $this->auth->user(); try { $article = $this->artcl->findById($id); if ($this->control->canByPass()) { $categories = $this->catRepo->getAll(); $states = $this->stateRepo->getAll(); } else { $categories = $this->catRepo->loadUserAvailableCats($user); $states = $this->stateRepo->loadUserAvailableStates($user); } } catch (NotFoundException $e) { } }
/** * ViewComposer constructor. * * @param AuthManager $auth The auth manager */ public function __construct(AuthManager $auth) { $this->authUser = $auth->user(); }
/** * Make permission instances by type * * @param string $type type string * @param MemberEntityInterface $user user instance * @param string $siteKey site key * @return Permission[] * @throws NotMatchedInstanceException */ public function makesByType($type, MemberEntityInterface $user = null, $siteKey = 'default') { $user = $user ?: $this->auth->user(); $permissions = []; $registereds = $this->repo->fetchByType($siteKey, $type); foreach ($registereds as $registered) { $ancestors = array_filter($registereds, function ($item) use($registered) { $itemNames = explode('.', $item->name); $registeredNames = explode('.', $registered->name); if (count($itemNames) >= count($registeredNames)) { return false; } for ($i = 0; $i < count($itemNames); $i++) { if ($itemNames[$i] !== $registeredNames[$i]) { return false; } } return true; }); if (count($ancestors) > 0) { uasort($ancestors, [$this, 'cmp']); } foreach ($ancestors as $ancestor) { $registered->addParent($ancestor); } if (isset($this->extends[$type]) === true) { $permission = $this->extends[$type]($registered->name, $user, $registered); if ($permission instanceof Permission === false) { throw new NotMatchedInstanceException(['type' => $type]); } $permissions[$registered->name] = $permission; } else { switch ($type) { case 'route': $route = $this->routes->getByName($registered->name); $permissions[$registered->name] = new RoutePermission($route, $user, $registered); break; case 'instance': $permissions[$registered->name] = new InstancePermission($registered->name, $user, $registered); break; } } } return $permissions; }
public function getUser() { return $this->authManager->user(); }
/** * Get the id of the currently authenticated user. * * @return int */ protected function getUserId() { return $this->auth->user()->id; }
public function update() { $this->updater->update($this->auth->user()->settings, Input::all()); return Redirect::back(); }
/** * Set user by auth * * @return $this */ public function setUserByAuth() { if ($this->auth->check()) { return $this->setUser($this->auth->user()); } }
/** * Get the currently authenticated user * * @return mixed */ public function user() { return $this->auth->user(); }
/** * */ public function updateLastSeen() { if ($this->isLoggedIn()) { $this->auth->user()->updateLastSeen(); } }