コード例 #1
0
ファイル: Locale.php プロジェクト: studiocaro/HorseStories
 /**
  * @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);
 }
コード例 #2
0
ファイル: BinController.php プロジェクト: sdlyhu/laravelio
 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]);
 }
コード例 #3
0
 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'));
 }
コード例 #4
0
 /**
  * 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();
 }
コード例 #5
0
 /**
  * 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);
 }
コード例 #6
0
 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]);
 }
コード例 #7
0
 /**
  * @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;
 }
コード例 #8
0
ファイル: SettingsForm.php プロジェクト: wmk223/site
 /**
  * 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;
 }
コード例 #9
0
 /**
  * @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;
 }
コード例 #10
0
ファイル: AuthCollector.php プロジェクト: focuslife/v0.1
 /**
  * @{inheritDoc}
  */
 public function collect()
 {
     try {
         $user = $this->auth->user();
     } catch (\Exception $e) {
         $user = null;
     }
     return $this->getUserInformation($user);
 }
コード例 #11
0
ファイル: DatabaseManager.php プロジェクト: leitom/role
 /**
  * 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');
 }
コード例 #12
0
ファイル: AccessFilter.php プロジェクト: anlutro/l4-core
 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);
         }
     }
 }
コード例 #13
0
 /**
  * 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);
 }
コード例 #14
0
 public function __construct(DriverLocationTransformer $driverLocationTransformer, AuthManager $authManager, JsonRespond $jsonRespond)
 {
     parent::__construct($jsonRespond);
     $this->user = $authManager->user();
     $this->jsonRespond = $jsonRespond;
     $this->driverLocationTransformer = $driverLocationTransformer;
 }
コード例 #15
0
 /**
  * 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);
 }
コード例 #16
0
 public function __construct(AuthManager $auth, OrderTransformer $orderTransformer, JsonRespond $jsonRespond)
 {
     parent::__construct($jsonRespond);
     $this->user = $auth->user();
     $this->orderTransformer = $orderTransformer;
     $this->jsonRespond = $jsonRespond;
 }
コード例 #17
0
 /**
  * 임시 데이터 저장
  *
  * @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);
 }
コード例 #18
0
ファイル: UserController.php プロジェクト: PhonemeCms/cms
 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);
 }
コード例 #19
0
ファイル: Support.php プロジェクト: boomcms/boom-core
 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'));
     });
 }
コード例 #20
0
ファイル: Guardian.php プロジェクト: aamirchaudhary/guardian
 /**
  * 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;
     }
 }
コード例 #21
0
 /**
  * @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;
 }
コード例 #22
0
 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) {
     }
 }
コード例 #23
0
 /**
  * ViewComposer constructor.
  *
  * @param AuthManager $auth The auth manager
  */
 public function __construct(AuthManager $auth)
 {
     $this->authUser = $auth->user();
 }
コード例 #24
0
ファイル: Factory.php プロジェクト: qkrcjfgus33/xpressengine
 /**
  * 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;
 }
コード例 #25
0
 public function getUser()
 {
     return $this->authManager->user();
 }
コード例 #26
0
ファイル: TrickOwner.php プロジェクト: qloog/site
 /**
  * Get the id of the currently authenticated user.
  *
  * @return int
  */
 protected function getUserId()
 {
     return $this->auth->user()->id;
 }
コード例 #27
0
 public function update()
 {
     $this->updater->update($this->auth->user()->settings, Input::all());
     return Redirect::back();
 }
コード例 #28
0
 /**
  * Set user by auth
  *
  * @return $this
  */
 public function setUserByAuth()
 {
     if ($this->auth->check()) {
         return $this->setUser($this->auth->user());
     }
 }
コード例 #29
0
 /**
  * Get the currently authenticated user
  *
  * @return mixed
  */
 public function user()
 {
     return $this->auth->user();
 }
コード例 #30
0
ファイル: UserManager.php プロジェクト: coandacms/coanda-core
 /**
  *
  */
 public function updateLastSeen()
 {
     if ($this->isLoggedIn()) {
         $this->auth->user()->updateLastSeen();
     }
 }