getUser() public method

Returns the currently logged in user, lazily checking for it.
public getUser ( boolean $check = true ) : Cartalyst\Sentinel\Users\UserInterface
$check boolean
return Cartalyst\Sentinel\Users\UserInterface
Example #1
0
 /**
  * @param View $view
  */
 public function compose(View $view)
 {
     $view->with('currentUser', $this->sentinel->getUser());
     $view->with('mode', array_get($view->getData(), 'mode', ''));
     $view->with('breadcrumbs', config('shapeshifter.breadcrumbs') ? $this->breadcrumbService->breadcrumbs() : []);
     $view->with('menu', $this->menuService->generateMenu());
 }
Example #2
0
 /**
  * Authenticate against the current service. A closure may be provided
  * for a callback upon authentication as a shortcut for subscribing
  * to an event.
  *
  * @param  string  $slug
  * @param  string  $callbackUri
  * @param  Closure  $callback
  * @param  bool  $remember
  * @return \Cartalyst\Sentinel\Users\UserInterface
  */
 public function authenticate($slug, $callbackUri, Closure $callback = null, $remember = false)
 {
     // If a callback is supplied, we'll treat it as a global linking
     // callback. Specific callbacks for registering and existing
     // users can be registered outside of this method.
     if ($callback) {
         $this->linking($callback);
     }
     $provider = $this->make($slug, $callbackUri);
     $token = $this->retrieveToken($provider);
     // We'll check if a user is already logged in. If so
     // Sentinel Social will link the logged in user.
     if ($user = $this->sentinel->getUser()) {
         $link = $this->linkLoggedIn($slug, $provider, $token, $user);
     } else {
         $link = $this->linkLoggedOut($slug, $provider, $token);
         $user = $link->getUser();
         $this->login($user, $remember);
     }
     return $user;
 }
Example #3
0
 /**
  * Get the currently authenticated user.
  *
  * @return \Cartalyst\Sentinel\Users\UserInterface
  */
 public function user()
 {
     return $this->sentinel->getUser();
 }
Example #4
0
 /**
  * Returns the currently logged in user, lazily checking for it.
  *
  * @param  bool $check
  *
  * @return User
  */
 public function getUser($check = true)
 {
     return $this->sentinel->getUser($check);
 }
Example #5
0
 /**
  * Returns the currently logged in user, lazily checking for it.
  *
  * @param bool $check
  * @return \Cartalyst\Sentinel\Users\UserInterface 
  * @static 
  */
 public static function getUser($check = true)
 {
     return \Cartalyst\Sentinel\Sentinel::getUser($check);
 }
Example #6
0
 /**
  * {@inheritDoc}
  */
 public function getActiveUser()
 {
     return $this->sentinel->getUser();
 }
 /**
  * Constructor.
  *
  * @param  \Cartalyst\Sentinel\Sentinel  $sentinel
  * @return void
  */
 public function __construct(Sentinel $sentinel)
 {
     $this->user = $sentinel->getUser();
 }
 /**
  * Constructor.
  *
  * @param  \Cartalyst\Cart\Cart  $cart
  * @param  \Cartalyst\Sentinel\Sentinel  $sentinel
  * @return void
  */
 public function __construct(Cart $cart, Sentinel $sentinel)
 {
     $this->cart = $cart;
     $this->wishlist = app('wishlist');
     $this->user = $sentinel->getUser();
 }
Example #9
0
 /**
  * Get value from the user to be saved as the author.
  *
  * @return string|null
  */
 protected function getUserFieldValue()
 {
     if ($user = $this->provider->getUser()) {
         return ($field = $this->field) ? (string) $user->{$field} : $user->getLogin();
     }
 }
Example #10
0
 /**
  * @param $route
  *
  * @return bool
  */
 private function hasAccessToRoute($route)
 {
     return !config('shapeshifter.menu_strict_auth_checking') || $route === null || $this->auth->getUser()->hasAnyAccess($route, 'superuser');
 }