Get the authenticated user.

Supported authentication systems: Laravel, Sentinel

@return array|null
320204
private function getUser()
    {
        if (function_exists('auth') && auth()->check()) {
            return auth()->user()->toArray();
        }

        if (class_exists(\Cartalyst\Sentinel\Sentinel::class) && $user = Sentinel::check()) {
            return $user->toArray();
        }

        return null;
    }
1033928
public function user()
    {
        if (self::$authorizedUser || !$_GET['state'] || (!$code = $_GET['code']) && $_GET['state']) {
            return self::$authorizedUser;
        }

        $permission = $this->getAccessPermission($code);

        if ($permission['scope'] !== 'snsapi_userinfo') {
            $user = ['openid' => $permission['openid']];
        } else {
            $user = $this->getUser($permission['openid'], $permission['access_token']);
        }

        return $this->authorizedUser = $user;
    }
995352
public function getUserData()
    {
        if (!$this->tokenStorage->getToken()
            || !$this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')
        ) {
            return null;
        }

        $user = $this->tokenStorage->getToken()->getUser();

        if (!$user) {
            return null;
        }

        return $this->userHelper->buildUserData($user);
    }
746896
public function getIdentity()
    {
        if($this->hasIdentity()){
            if($this->identity === null){
                
                $identity = $this->authenticationService->getIdentity();
                $identity = array_merge(
                    $identity,
                    $this->getOption('identity')        
                );
                
                // Extend with real identity information
                if ($this->getServiceBroker()->exists('User')) {
                    $userService = $this->getServiceBroker()->service('User');
                    
                    // Access filter needs to be disabled to prevent infinite looping
                    $userService->disableFilter('access');
                    
                    $extension = $userService->find(
                        '$'.$identity['username'],
                        array('id', 'email')
                    );
                    
                    if ($extension) {
                        $identity = array_merge($identity, $extension);
                    }
                }
                
                $this->identity = $identity;
            }
            
            return $this->identity;
        }
        else{
            return null;
        }
    }
849555
public function getUser() {
        $session = $this->session_manager->session;

        if ($session && !$this->user) {
            $user_id = $session->get(Auth::getName());

            if ($user_id && is_null($this->user)) {
                $user_model = Config::get('auth.providers.users.model');

                if ($user_model) {
                    $this->user = $user_model::find($user_id);
                }
            } else {
                $this->user = null;
            }
        }

        return $this->user;
    }
250242
public function getUser()
    {
        if (null === $token = $this->security->getToken()) {
            return null;
        }

        $user = $token->getUser();

        if (! is_object($user)) {
            return null;
        }

        return $user;
    }
1043022
protected function getUser()
    {
        if ($this->_user === null) {
            $user = \thienhungho\UserManagement\models\User::findByUsername($this->username);
            $this->_user = $user;
        }

        return $this->_user;
    }
1328095
protected function getAuthUserId()
    {
        $token = $this->tokenStorage->getToken();
        if (null === $token) {
            return;
        }

        $user = $token->getUser();
        if (!is_object($user)) {
            return;
        }

        return $user->getId();
    }
1063369
protected function getLoggedUser()
    {
        $user = $this->get('security.token_storage')->getToken()->getUser();
        if (is_string($user)) {
            $user = null;
        }

        return $user;
    }
274661
public function login()
    {
        if ($this->validate()) {
            $this->trigger(self::GET_ACCESS_TOKEN);
            if($this->_user != null) {
                $this ->_user = User::findByUsername($this->username);
            }
            return $this->_user;
        } else {
            return null;
        }
    }
1252462
public function getUser()
    {
        if ($user = $this->provider->user()) {
            return ($field = $this->field) ? (string) $user->{$field} : $user->getAuthIdentifier();
        }
    }
1338047
private function get_user() {
        $userid = $this->backuprec->userid;
        $user = core_user::get_user($userid, '*', MUST_EXIST);

        return $user;
    }
1315295
public function userResponsible()
    {
        if (empty($this->user_id)) { return false; }
        if (class_exists($class = '\Cartalyst\Sentry\Facades\Laravel\Sentry')
            || class_exists($class = '\Cartalyst\Sentinel\Laravel\Facades\Sentinel')
        ) {
            return $class::findUserById($this->user_id);
        } else {
            $user_model = app('config')->get('auth.model');

            if (empty($user_model)) {
                $user_model = app('config')->get('auth.providers.users.model');
                if (empty($user_model)) {
                    return false;
                }
            }
            if (!class_exists($user_model)) {
                return false;
            }
            return $user_model::find($this->user_id);
        }
    }
983451
public function authenticated()
    {
        if (!$this->checkAuth()) {
            return response()->json(null, 401);
        }

        return response()->json(arrayView('phpsoft.users::user/read', [
            'user' => Auth::user()
        ]), 200);
    }
1312778
private function authenticateBySession()
    {
        $u = $this->userFactory()->create($this->userType());
        // Call static method on user
        $u = call_user_func([get_class($u), 'getAuthenticated'], $this->userFactory());

        if ($u && $u->id()) {
            $u->saveToSession();

            return $u;
        } else {
            return null;
        }
    }
1284545
public function user()
    {
        // If we've already retrieved the user for the current request we can just
        // return it back immediately. We do not want to fetch the user data on
        // every call to this method because that would be tremendously slow.
        if (! is_null($this->user)) {
            return $this->user;
        }

        $user = null;

        // If a user ID was provided in the JWT, then
        // we should attempt to fetch their profile.
        if (! empty($this->id())) {
            $user = $this->provider->retrieveById($this->id());
        }

        return $this->user = $user;
    }
90265
public function getuser(){
		if(empty($this->user)){
			return NULL;
			}
		bimport('users.general');
		$bu=BUsers::getInstance();
		$user=$bu->itemGet($this->user);
		return $user;
		}