public function actionLogin() { // authenticate user if form data POSTed if ($this->request->getPost('username')) { $username = Fari_Decode::accents($this->request->getPost('username')); $password = Fari_Decode::accents($this->request->getPost('password')); $this->user = new Fari_AuthenticatorSimple(); if ($this->user->authenticate($username, $password, $this->request->getPost('token'))) { $this->redirectTo('/'); } else { $this->flashFail = 'Sorry, your username or password wasn\'t recognized'; } } $this->flashNotify = 'Use \'admin\' for username and password.'; // create token & display login form $this->bag->token = Fari_FormToken::create(); $this->renderAction(); }
function __construct($username, $password, $token = NULL) { $authenticator = new Fari_AuthenticatorSimple(); // authenticator authenticates... if ($authenticator->authenticate($username, $password, $token) != TRUE) { throw new UserNotAuthenticatedException(); } else { // return the sweet beans return new User(); } }