The firewall class check if users is authenticated and holds the methods for authentication.
상속: use trait Webiny\Component\Http\HttpTrait, use trait Webiny\Component\StdLib\StdLibTrait, use trait Webiny\Component\StdLib\FactoryLoaderTrait, use trait Webiny\Component\EventManager\EventManagerTrait
예제 #1
0
 /**
  * This method verifies the credentials of current user with the credentials provided from the Login object.
  *
  * @param Login    $login
  * @param Firewall $firewall
  *
  * @throws \Exception
  * @return bool Return true if credentials are valid, otherwise return false.
  */
 public function authenticate(Login $login, Firewall $firewall)
 {
     try {
         $result = $firewall->verifyPasswordHash($login->getPassword(), $this->getPassword());
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage());
     }
     return $result;
 }
예제 #2
0
파일: User.php 프로젝트: Webiny/Framework
 /**
  * This method verifies the credentials of current user with the credentials provided from the Login object.
  *
  * @param Login    $login
  * @param Firewall $firewall
  *
  * @return bool Return true if credentials are valid, otherwise return false.
  */
 public function authenticate(Login $login, Firewall $firewall)
 {
     $user = call_user_func_array([$this->entity, 'findOne'], [[$this->username => $login->getUsername()]]);
     if ($user) {
         if ($firewall->verifyPasswordHash($login->getPassword(), $user[$this->password])) {
             if (isset($user[$this->role])) {
                 $role = $user[$this->role];
             } else {
                 $role = $this->role;
             }
             $role = new Role($role);
             $this->setRoles([$role]);
             return true;
         }
     }
     return false;
 }
예제 #3
0
파일: User.php 프로젝트: Nkelliny/Framework
 /**
  * This method verifies the credentials of current user with the credentials provided from the Login object.
  *
  * @param Login    $login
  * @param Firewall $firewall
  *
  * @return bool Return true if credentials are valid, otherwise return false.
  */
 public function authenticate(Login $login, Firewall $firewall)
 {
     $entityInstance = new $this->entity();
     $user = $entityInstance->find([$this->username => $login->getUsername()]);
     if ($user && isset($user[0])) {
         $user = $user[0];
         if ($firewall->verifyPasswordHash($login->getPassword(), $user[$this->password])) {
             if (isset($user[$this->role])) {
                 $role = $user[$this->role];
             } else {
                 $role = $this->role;
             }
             $role = new Role($role);
             $this->setRoles([$role]);
             return true;
         }
     }
     return false;
 }
예제 #4
0
 /**
  * @param Firewall $firewall
  *
  * @dataProvider firewallProvider
  */
 public function testGetFirewallKey($firewall)
 {
     $this->assertSame('Admin', $firewall->getFirewallKey());
 }