public
Last active

Aqui estaran las funcionalidades de login y registro controller_Account

  • Download Gist
account.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Controller_Account
*
* Aqui estaran las funcionalidades de login y registro
*
* @author Javier
* @package Backend
*
*/
class Controller_Account extends Controller {
 
/**
*
* @var User $auth contains object a1 user
*/
public $auth;
public $session;
public $view;
public function before()
{
parent::before();
$this->auth = A1::instance();
$this->session = Session::instance();
}
public function action_index()
{
$this->action_login();
}
public function action_login()
{
$errors = array();
if($this->request->method()=="POST")
{
$username = Arr::get($_POST, 'username');
$password = Arr::get($_POST, 'password');
$remember = (isset($_POST['remember']))?TRUE:FALSE;
if($this->auth->login($username,$password,$remember ))
{
$session = $this->auth->session()->as_array();
$session["user"] = $this->auth->get_user();
$this->session = $session;
$this->request->redirect(Route::url('default',array('controller' => 'backend','action' => FALSE)));
}
else
{
$errors['login'] = "Datos no validos";
}
}
$this->view = View::factory('backend/login')
->set("errors",$errors);
}
public function action_register()
{
if($this->request->method()== "POST")
{
}
else
{
$this->view = View::factory('backend/register');
}
}
public function after()
{
$this->response->body($this->view);
parent::after();
}
 
} // End Account

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.