function hashAction($password = "") { if (!strlen($password)) { throw new \Exception("Please specify a password to hash."); } $action = new \Actions\Users\Auth(); echo $action->hashPassword($password) . PHP_EOL; }
/** * Kill the session and login cookie */ public function logoutAction() { $action = new \Actions\Users\Auth(); $action->destroyToken(); $action->destroySession(); $this->cookies->get('token')->delete(); $this->addMessage("You've been logged out"); }
/** * Sets up the session data, builds the user info */ public function init() { // save the userId from the session $this->userId = $this->getDI()->getShared('session')->get('user_id'); // read in the session. if it's not set, try to re-authorize them // with a login token. authorizeToken will set the session info // if a valid token exists. if (!$this->isLoggedIn()) { $action = new \Actions\Users\Auth(); if (!$action->authorizeToken()) { return FALSE; } // update the auth from the session $this->userId = $this->getDI()->getShared('session')->get('user_id'); } // load user, roles, and settings. if the requested userId is the // same as the session, then just use the session user. $this->load($this->userId); }
/** * @group actions * @group users * @group auth */ public function testDestroyCookieSession() { $action = new \Actions\Users\Auth(); $this->assertTrue($action->destroyToken(1)); $this->assertTrue($action->destroySession()); $session = $this->di->get('session'); $this->assertFalse(valid($session->get('user_id'))); }