public function afterInsert()
 {
     $user = $this->getUser();
     $identity = new Identity();
     $identity->auth_provider = $this->authProviderName;
     $identity->external_user_id = $this->externalUserId;
     $identity->internal_user_id = $user->id;
     if (!$identity->save()) {
         throw new Exception('Failed to save identity. Errors: ' . print_r($identity->errors, true));
     }
 }
예제 #2
0
파일: AuthForm.php 프로젝트: iw-reload/iw
 /**
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $externalIdentity = Identity::findOne(['auth_provider' => $this->authProvider, 'external_user_id' => $this->externalUserId]);
         $this->_user = $externalIdentity instanceof Identity ? $externalIdentity->internalUser : null;
     }
     return $this->_user;
 }