Advertisement
Guest User

Untitled

a guest
May 12th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. <?php defined('SYSPATH') OR die('No direct access allowed.');
  2.  
  3. class User_Model extends Model
  4. {
  5.  
  6.     public $auth;
  7.  
  8.     public function __construct()
  9.     {
  10.             parent::__construct();
  11.     }
  12.  
  13.     public function login()
  14.     {
  15.         $this->input = Kohana::instance()->input;
  16.         $username = $this->input->post('username');
  17.         $password = $this->input->post('password');
  18.  
  19.  
  20.         $user = ORM::factory('user', $username);
  21.         $this->auth = new Auth();
  22.  
  23.         $user->username = $username;
  24.         $user->password = $password;
  25.  
  26.            
  27.         if ($this->auth->logged_in('admin')) // if admin is already logged in
  28.         {
  29.             // send to admin backend
  30.             url::redirect('admin/');
  31.         } else if ($this->auth->logged_in($username)) { // if user is already logged in
  32.             // send to customer area
  33.             url::redirect('customer/');
  34.         } else {
  35.             // perform login
  36.             $this->auth->login($user, $password);
  37.             // send to customer area
  38.             url::redirect('customer/');
  39.         }
  40.  
  41.  
  42.  
  43.  
  44.  
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement