/** * Register a new user account from a social login provider * * @param LoginRequest $request * @return array Array containing user and social login */ public function registerFromSocialLogin(LoginRequest $request) { $email = $request->getEmails()[0]; $user = $this->userService->registerWithoutPassword(array('email' => $email)); $socialLoginEntity = new SocialLoginEntity(); $socialLoginEntity->setUserId($user->getId())->setProvider($request->getProvider())->setProviderUserId($request->getProviderUserId())->setAccessToken($request->getAccessToken())->setAccessTokenExpires($request->getAccessTokenExpires())->setRefreshToken($request->getRefreshToken()); $entity = $this->socialLoginMapper->persist($socialLoginEntity); return array('user' => $user, 'social_login' => $entity); }
/** * 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); }