71 lines
1.9 KiB
PHP
71 lines
1.9 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
* This class provides login capability
|
|
*
|
|
* @package lnApp
|
|
* @category Controllers
|
|
* @author Deon George
|
|
* @copyright (c) 2009-2013 Deon George
|
|
* @license http://dev.leenooks.net/license.html
|
|
* @also [logout]
|
|
*/
|
|
class lnApp_Controller_Login extends Controller_TemplateDefault {
|
|
protected $auth_required = FALSE;
|
|
|
|
public function action_index() {
|
|
$output = '';
|
|
|
|
// If user already signed-in
|
|
if (Auth::instance()->logged_in())
|
|
HTTP::redirect(URL::link('user','welcome/index'));
|
|
|
|
// If there is a post and $_POST is not empty
|
|
if ($_POST) {
|
|
// If the post data validates using the rules setup in the user model
|
|
if (Auth::instance()->login($_POST['username'],$_POST['password'])) {
|
|
// Redirect to the user account
|
|
if ($redir = Session::instance()->get('afterlogin')) {
|
|
Session::instance()->delete('afterlogin');
|
|
HTTP::redirect($redir);
|
|
|
|
} else
|
|
HTTP::redirect(URL::link('user','welcome/index'));
|
|
|
|
} else {
|
|
SystemMessage::factory()
|
|
->title(_('Invalid username or password'))
|
|
->type('error')
|
|
->body(_('The username or password was invalid.'));
|
|
}
|
|
}
|
|
|
|
$oauthlogin = is_null($x=Session::instance()->get_once('login-no-oauth',NULL)) ? TRUE : ! $x;
|
|
$output .= View::factory('pages/login')
|
|
->set('oauth',$oauthlogin);
|
|
|
|
Style::factory()
|
|
->type('file')
|
|
->data('media/theme/baseadmin/css/pages/login.css');
|
|
|
|
Style::factory()
|
|
->type('file')
|
|
->data('media/css/auth-buttons.css');
|
|
|
|
if ($oauthlogin)
|
|
foreach (ORM::factory('Oauth')->list_active() as $oo)
|
|
$output .= $oo->plugin()->html();
|
|
|
|
$this->template->content = $output;
|
|
$this->template->shownavbar = FALSE;
|
|
}
|
|
|
|
public function action_noaccess() {
|
|
SystemMessage::factory()
|
|
->title(_('No access to requested resource'))
|
|
->type('error')
|
|
->body(_('You do not have access to the requested resource, please contact your administrator.'));
|
|
}
|
|
}
|
|
?>
|