Advertisement
Guest User

Untitled

a guest
Nov 9th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. //Controller_Api_Admin_Login
  2. public function post_validate()
  3. {
  4.     $arg = array();
  5.     $arg['email']       = \Fuel\Core\Input::post('email');
  6.     $arg['password']    = \Fuel\Core\Input::post('password');
  7.        
  8.     $response = Model_User::validate_user($arg);
  9.        
  10.     return $this->response($response);
  11. }
  12.  
  13. //Model User
  14. public static function validate_user($arg)
  15. {
  16.     $q = Model_User::query()
  17.         ->where('email','=',$arg['email']);
  18.        
  19.     $msg = 'Invalid username password';
  20.     $res['success'] = false;
  21.     $res['response']= $msg;
  22.     if($q->count() == 1)
  23.     {
  24.         $cred = $q->get_one();
  25.         $verified = myauth2\auth::compare_password($cred['salt'],$cred['hash'],$arg['password']);
  26.         $res['response'] = $msg;
  27.         if($verified)
  28.         {
  29.             Session::set('email',$cred['email']);
  30.             Session::set('type',$cred['type']);
  31.             Session::set('user_id',$cred['id']);
  32.             Session::set('username',$cred['username']);
  33.             Session::set('su',$cred['su']);
  34.             $res['response'] = 'Account verified';
  35.         }
  36.         $res['success'] = $verified;
  37.         }
  38.     return $res;
  39. }
  40.  
  41. // REST API Returned
  42. {"success":true,"response":"Account verified"}��������������������������������������������������������������������������������������������������������������������������������������������������������������
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement