예제 #1
0
파일: User.php 프로젝트: hiqdev/hi3a
 /**
  * Finds user through RemoteUser
  */
 public static function findIdentityByAuthClient($client)
 {
     $provider = RemoteUser::toProvider($client->getId());
     if (!$provider) {
         return null;
     }
     $attributes = $client->getUserAttributes();
     $remoteid = $attributes['id'];
     $email = $attributes['email'];
     $remote = RemoteUser::findOne(compact('provider', 'remoteid'));
     if ($remote) {
         return static::findOne($remote->client_id);
     }
     $user = static::findByEmail($email);
     if (!$user) {
         return null;
     }
     if (RemoteUser::isTrustedEmail($provider, $email)) {
         return RemoteUser::set($client, $user);
     }
     #Yii::$app->getSession()->set('');
     return null;
 }
예제 #2
0
 public function actionSignup()
 {
     $client = Yii::$app->authClientCollection->getActiveClient();
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 if ($client) {
                     RemoteUser::set($client, $user);
                 }
                 return $this->goHome();
             }
         }
     } else {
         if ($client) {
             $model->load([$model->formName() => $client->getUserAttributes()]);
         }
     }
     return $this->render('signup', compact('model'));
 }