Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('SYSPATH') OR die('No direct access allowed.');
- class User_Model extends Model
- {
- public $auth;
- public function __construct()
- {
- parent::__construct();
- }
- public function login()
- {
- $this->input = Kohana::instance()->input;
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $user = ORM::factory('user', $username);
- $this->auth = new Auth();
- $user->username = $username;
- $user->password = $password;
- if ($this->auth->logged_in('admin')) // if admin is already logged in
- {
- // send to admin backend
- url::redirect('admin/');
- } else if ($this->auth->logged_in($username)) { // if user is already logged in
- // send to customer area
- url::redirect('customer/');
- } else {
- // perform login
- $this->auth->login($user, $password);
- // send to customer area
- url::redirect('customer/');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement