예제 #1
0
 public function authenticateByVk()
 {
     try {
         $vkToken = $this->session->get(C::PARAM_VK_TOKEN);
         $vkUserId = $this->session->get(C::PARAM_VK_USER_ID);
     } catch (\Exception $e) {
         throw new \Exception('vk session params not found');
     }
     if ($user = $this->userModel->getUserByVkAccountId($vkUserId)) {
         $this->forceAuthenticate($user);
         return true;
     }
     $userInfo = $this->vkApi->getUserInfo();
     $user = $this->createUser($userInfo['screen_name'], CommonFunction::generatePassword(12), $userInfo['screen_name']);
     $user->setVkAccountId($vkUserId);
     $this->em->flush();
     $this->forceAuthenticate($user);
     return true;
 }