Example #1
0
 public function getUserByFedKey()
 {
     if ($this->fedkey == null) {
         return null;
     }
     return UserProfile::getLocalUserById($this->getLocalUserByIdId());
     return true;
 }
Example #2
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);
 }