示例#1
0
 /**
  * Attempts to authenticate a TokenInterface object.
  *
  * @param TokenInterface $token The TokenInterface instance to authenticate
  *
  * @return TokenInterface An authenticated TokenInterface instance, never null
  *
  * @throws AuthenticationException if the authentication fails
  */
 public function authenticate(TokenInterface $token)
 {
     if ($this->userProvider instanceof ChainUserProvider) {
         foreach ($this->userProvider->getProviders() as $provider) {
             $result = $this->doAuth($provider, $token);
             if ($result !== false) {
                 return $result;
             }
         }
     } else {
         $result = $this->doAuth($this->userProvider, $token);
         if ($result !== false) {
             return $result;
         }
     }
 }
示例#2
0
 /**
  * @param                       $user
  * @param TokenInterface        $token
  * @param UserProviderInterface $userProvider
  * @param Request               $request
  * @param bool                  $loginCheck            Event executed from the mautic_sso_login_check route typically used as the SSO callback
  * @param string                $authenticatingService Service Service requesting authentication
  * @param null                  $integrations
  */
 public function __construct($user, TokenInterface $token, UserProviderInterface $userProvider, Request $request, $loginCheck = false, $authenticatingService = null, $integrations = null)
 {
     $this->token = $token;
     $this->user = $user;
     $this->isFormLogin = $token instanceof UsernamePasswordToken;
     $this->integrations = $integrations;
     $this->request = $request;
     $this->isLoginCheck = $loginCheck;
     $this->authenticatingService = $authenticatingService;
     if ($userProvider instanceof ChainUserProvider) {
         // Chain of user providers so let's find Mautic's
         $providers = $userProvider->getProviders();
         foreach ($providers as $provider) {
             if ($provider instanceof UserProvider) {
                 $userProvider = $provider;
                 break;
             }
         }
     }
     $this->userProvider = $userProvider;
 }