Exemplo n.º 1
0
Arquivo: User.php Projeto: 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;
 }
Exemplo n.º 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'));
 }