public function loadUserByUsername($username)
    {
        $slackUser = $this->client->getSlackUserFromOAuthCode($username);

        if (!$slackUser->isValid()) {
            throw new UsernameNotFoundException('No access token found.');
        }

        $user = $this->userService->findBySlackUserId($slackUser->getUserId());

        if (!empty($user)) {
            return $user;
        }

        $user = $this->userService->findUserByEmail($slackUser->getEmail());

        if (!empty($user)) {
            $user->setSlackUserId($slackUser->getUserId());

            return $user;
        }

        return $this->registerUser($slackUser);
    }
public function loadUserByUsername($username)
    {
        $slackUser = $this->client->getSlackUserFromOAuthCode($username);

        if (!$slackUser->isValid()) {
            throw new UsernameNotFoundException('No access token found.');
        }

        $user = $this->userService->findBySlackUserId($slackUser->getUserId());

        if (!empty($user)) {
            return $user;
        }

        $user = $this->userService->findUserByEmail($slackUser->getEmail());

        if (!empty($user)) {
            $user->setSlackUserId($slackUser->getUserId());

            return $user;
        }

        return $this->registerUser($slackUser);
    }
public function loadUserByUsername ( $ username ) { $ slackUser = $ this -> client -> getSlackUserFromOAuthCode ( $ username ) ; if ( ! $ slackUser -> isValid ( ) ) { throw new UsernameNotFoundException ( 'No access token found.' ) ; } $ user = $ this -> userService -> findBySlackUserId ( $ slackUser -> getUserId ( ) ) ; if ( ! empty ( $ user ) ) { return $ user ; } $ user = $ this -> userService -> findUserByEmail ( $ slackUser -> getEmail ( ) ) ; if ( ! empty ( $ user ) ) { $ user -> setSlackUserId ( $ slackUser -> getUserId ( ) ) ; return $ user ; } return $ this -> registerUser ( $ slackUser ) ; }
Fetches the user from slack

@param string $username
@return null|object|BaseUser
Fetches the user from slack