public function actionTestVote() { Vote::processVote(); /*$user = User::findOne(['social_id' => Yii::$app->user->identity->social_id]); $vote = new Vote(); $vote->user_id = $user->id; $vote->questions_id = Yii::$app->session->get('question_id'); $vote->vote = 1; $vote->save(); echo '<pre>'; print_r($vote); print_r( $vote->getErrors());*/ }
public function actionSocialLogin() { $serviceName = Yii::$app->getRequest()->get('service'); if (isset($serviceName)) { /** @var $eauth \nodge\eauth\ServiceBase */ $eauth = Yii::$app->get('eauth')->getIdentity($serviceName); $eauth->setRedirectUrl(Yii::$app->getUser()->getReturnUrl()); $eauth->setCancelUrl(Yii::$app->getUrlManager()->createAbsoluteUrl('site/login')); try { if ($eauth->authenticate()) { // var_dump($eauth->getIsAuthenticated(), $eauth->getAttributes()); exit; $identity = User::findByEAuth($eauth); Yii::$app->getUser()->login($identity); Vote::processVote(); // special redirect with closing popup window //$eauth->redirect(Yii::$app->request->referrer); $eauth->redirect(Yii::$app->getUrlManager()->createAbsoluteUrl('thanks.html')); } else { // close popup window and redirect to cancelUrl $eauth->cancel(); } //return $this->redirect('/'); return $this->redirect(Yii::$app->request->referrer); } catch (\nodge\eauth\ErrorException $e) { // save error to show it later Yii::$app->getSession()->setFlash('error', 'EAuthException: ' . $e->getMessage()); // close popup window and redirect to cancelUrl // $eauth->cancel(); $eauth->redirect($eauth->getCancelUrl()); } } }