Пример #1
0
 /**
  * Handle a request to log in via a social login provider
  *
  * @param  LoginRequest $request
  * @return array        Access token
  */
 public function handleLoginRequest(LoginRequest $request)
 {
     $socialLogin = $this->socialLoginMapper->findByProviderUserId($request->getProvider(), $request->getProviderUserId());
     if ($socialLogin) {
         $user = $this->userService->findById($socialLogin->getUserId());
         $this->updateSocialLoginToken($socialLogin, $request);
         return $this->handleLogin($user, $request);
     }
     $userFound = false;
     foreach ($request->getEmails() as $email) {
         $user = $this->userService->findByEmail($email);
         if ($user) {
             $userFound = true;
             if ($this->userHasSocialLoginWithProvider($request->getProvider(), $user)) {
                 return $this->handleLogin($user, $request);
             }
         }
     }
     if ($userFound) {
         throw new NoLinkedAccountException();
     }
     $result = $this->registerFromSocialLogin($request);
     return $this->handleLogin($result['user']);
 }
Пример #2
0
 /**
  * Get the user from the request
  *
  * @param  Request $request
  * @return UserEntity|boolean
  */
 protected function getUserFromRequest(Request $request)
 {
     $username = $request->get('username');
     return $this->userService->findByEmail($username);
 }