/** * @param string $email * @param string $password * @return bool */ public function login($email, $password) { if ($email && $password) { $userclass = $this->userclass; $user = $userclass::findOneByEmail($email); if ($user) { //utente trovato, verificare credenziali if ($this->verify($password, $user->password) === true) { /* If correct create session */ session_regenerate_id(); self::$_user = $user; $_SESSION['member'] = $user->toArray(); unset($_SESSION['member']['password']); $_SESSION['member_id'] = $user->id; $_SESSION['member_valid'] = true; $_SESSION['member_type'] = $user::USERTYPE; $_SESSION['userObj'] = $user; /* User Remember me feature? */ //$this->createNewCookie($user->id); return true; } else { // password sbagliata return false; } } else { // utente non trovato, riproponi login return false; } } else { // mancano dati, riproponi login return false; } }
/** * Retrieves the current Zigra_User object. * * @param object $userclass User class that retrieves user data from database * * @return Zigra_User The current Zigra_User implementation instance */ public function getUser($userclass) { return Zigra_User::singleton($userclass); }