예제 #1
0
 public function getUserByFedKey()
 {
     if ($this->fedkey == null) {
         return null;
     }
     return UserProfile::getLocalUserById($this->getLocalUserByIdId());
     return true;
 }
 public function getValidatorInstance()
 {
     $validator = parent::getValidatorInstance();
     $validator->after(function () use($validator) {
         $input = $this->formatInput();
         $checkcode = trim(strtoupper($input['checkcode']));
         if ($checkcode[2] != '-' || strlen($checkcode) != 9) {
             $validator->errors()->add('checkcode', 'profile.invalide-code-format');
             return $validator;
         }
         $localuser = UserProfile::findLocalUserByVerificationCode($input['checkcode']);
         if ($localuser == null) {
             $validator->errors()->add('checkcode', Lang::get("profile.invalid-code-value"));
         }
     });
     return $validator;
 }
예제 #3
0
 protected function federateAndLog($socialuser)
 {
     // 1) If user is already federated let login and return
     if ($socialuser->fedkey != null) {
         // get user directly from his federation key
         $localuser = UserProfile::getLocalUserById($socialuser->getLocalUserId());
         // if logged user points to other account let's notify this information
         if ($this->auth->check()) {
             $loggeduser = UserProfile::getLocalUserById($this->auth->id());
             if ($loggeduser->id != $localuser->id) {
                 Session::flash('alert', ['profile.user-federate-dup', $loggeduser->pseudonym]);
             }
         }
         return $this->userHasLoggedIn($localuser, $socialuser->provider->loa);
     }
     // 2) user is logged let add this IDP to his federation list
     if ($this->auth->check()) {
         $localuser = UserProfile::getLocalUserById($this->auth->id());
         // federate social user with its provider
         $socialuser->federate($localuser);
         // log user in application
         return $this->userHasLoggedIn($localuser, $socialuser->provider->loa);
     }
     // 3) User is neither log neither federated let request for consent
     return $this->getConsent($socialuser);
 }