Show LoginController.php syntax highlighted
<?php
/**
* Astrum Futura: Open Source Space Strategy Game
*
* LICENSE
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@astrumfutura.com so we can send you a copy immediately.
*
* @category Astrum
* @package Astrum_Controller
* @copyright Copyright (c) 2006 Pádraic Brady (http://blog.quantum-star.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @version $Id$
*/
/**
* Login Controller
*
* @category Astrum
* @package Astrum_Controller
* @copyright Copyright (c) 2006 Pádraic Brady (http://blog.quantum-star.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
*/
class LoginController extends Astrum_Controller_Action
{
/**
* Process the form data and perform authentication.
*
* @access public
* @todo Utilise feyd's SHA256 class for hashing passwords
* @todo Implement challenge/response system
*/
public function indexAction()
{
/*
* Check request type, and redisplay form if not POST
*/
if($this->getRequest()->getMethod() !== 'POST' || !isset($this->_post))
{
$this->_forward('index', 'index');
return;
}
$credentials = new Astrum_User;
$credentials->name = $this->_post->getRaw('astrum_form_login_user');
$credentials->password = sha1($this->_post->getRaw('astrum_form_login_pass'));
$authenticator = new Astrum_Auth_Adapter_Simple;
$token = $authenticator->authenticate($credentials, new Astrum_User, $this->_session);
if(!$token->isValid())
{
$this->getResponse()->appendBody(
'<strong>' . $token->getMessage() . '</strong>'
);
$this->_forward('index', 'index');
return;
}
$user = $token->getIdentity();
$this->_session->user = $user->asArray();
$this->_view->user = $this->_session->user;
$this->getResponse()->appendBody(
$this->_view->render('login_index.tpl.html')
);
}
public function formAction()
{
$this->_view->authenticated = $this->_session->authenticated;
$this->getResponse()->appendBody(
$this->_view->render('login_form.tpl.html')
);
}
}
See more files for this project here