Nette\Security\User::login PHP Method

login() public method

Conducts the authentication process. Parameters are optional.
public login ( $id = NULL, $password = NULL ) : void
return void
    public function login($id = NULL, $password = NULL)
    {
        $this->logout(TRUE);
        if (!$id instanceof IIdentity) {
            $id = $this->getAuthenticator()->authenticate(func_get_args());
        }
        $this->storage->setIdentity($id);
        $this->storage->setAuthenticated(TRUE);
        $this->onLoggedIn($this);
    }

Usage Example

Example #1
0
 public function login($roleName)
 {
     $identity = new User();
     $identity->id = 0;
     $identity->email = '*****@*****.**';
     $identity->name = 'Name';
     $identity->surname = 'Surname';
     $identity->active = TRUE;
     $identity->registered = new DateTime();
     $identity->lastLogin = new DateTime();
     $identity->lang = 'cs';
     switch ($roleName) {
         case 'admin':
             $identity->id = 1;
             $role = new Role();
             $role->id = 1;
             $role->name = 'administrator';
             $identity->addRole($role);
             break;
         default:
             $role = new Role();
             $role->id = 1;
             $role->name = $roleName;
             $identity->addRole($role);
     }
     $this->user->login($identity);
 }
All Usage Examples Of Nette\Security\User::login