/** * Logs in the user * @param string $finder finder column * @param string $password password used to authenticate the user * @param boolean $remember session or cookie * @return NULL */ public function login($finder = null, $password = null, $remember = false) { $user = $this->_userModel->where($this->_config['finder'], $finder)->first(); if ($user === null) { throw new AuthException(ucfirst($this->_config['finder']) . ' does not exist'); } if ($password === null) { throw new AuthException('Password cannot be empty'); } // Tarpit alert! // Let PHP sleep for just one seconds, prevend DoS-attacks (becase, takes too long) // and stresses the shit out of k1dd0z sleep(1); if (password_verify($password, $user->password)) { Cookie::set('stativo_auth_session', $user->token, $remember ? 2592000 : null); // one month! return true; } else { return false; } }
/** * Set a notification * * ~~ Do not use the set/get method directly in the view! This will cause problems! ~~ * * @param string $value Value of the notification */ public static function set($value) { Cookie::set('__notification', $value); }