Ejemplo n.º 1
1
 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);
     }
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 /**
  * 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);
 }
Ejemplo n.º 5
0
 /**
  * Authenticate request.
  *
  * @return bool|exception
  */
 public function auth()
 {
     if (!$this->auth->attempt($this->getCredentials())) {
         throw new InvalidBasicAuthCredentials();
     }
     return true;
 }
Ejemplo n.º 6
0
 /**
  * @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);
 }
Ejemplo n.º 7
0
 /**
  * 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);
 }
Ejemplo n.º 8
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'));
 }
Ejemplo n.º 9
0
 public function __construct(AuthManager $auth, OrderTransformer $orderTransformer, JsonRespond $jsonRespond)
 {
     parent::__construct($jsonRespond);
     $this->user = $auth->user();
     $this->orderTransformer = $orderTransformer;
     $this->jsonRespond = $jsonRespond;
 }
Ejemplo n.º 10
0
 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]);
 }
Ejemplo n.º 11
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 ($user = $this->auth->getUser()) {
         return $user;
     }
     throw new UnauthorizedHttpException(null, 'Please log in before perform this query.');
 }
Ejemplo n.º 12
0
 /**
  * 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;
 }
Ejemplo n.º 13
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;
 }
Ejemplo n.º 14
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);
 }
Ejemplo n.º 15
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();
 }
Ejemplo n.º 16
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]);
 }
Ejemplo n.º 17
0
 /**
  * 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;
 }
Ejemplo n.º 18
0
 /**
  * @{inheritDoc}
  */
 public function collect()
 {
     try {
         $user = $this->auth->user();
     } catch (\Exception $e) {
         $user = null;
     }
     return $this->getUserInformation($user);
 }
Ejemplo n.º 19
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;
 }
Ejemplo n.º 20
0
 /**
  * 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();
 }
Ejemplo n.º 22
0
 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'));
     });
 }
Ejemplo n.º 23
0
 /**
  * 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);
 }
Ejemplo n.º 24
0
 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);
         }
     }
 }
Ejemplo n.º 25
0
 /**
  * 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();
 }
Ejemplo n.º 26
0
 /**
  * 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;
 }
Ejemplo n.º 27
0
 /**
  * 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);
 }
Ejemplo n.º 28
0
 /**
  * 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;
 }
Ejemplo n.º 29
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);
 }
Ejemplo n.º 30
0
 /**
  * @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);
 }