Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Controller_Api_Admin_Login
- public function post_validate()
- {
- $arg = array();
- $arg['email'] = \Fuel\Core\Input::post('email');
- $arg['password'] = \Fuel\Core\Input::post('password');
- $response = Model_User::validate_user($arg);
- return $this->response($response);
- }
- //Model User
- public static function validate_user($arg)
- {
- $q = Model_User::query()
- ->where('email','=',$arg['email']);
- $msg = 'Invalid username password';
- $res['success'] = false;
- $res['response']= $msg;
- if($q->count() == 1)
- {
- $cred = $q->get_one();
- $verified = myauth2\auth::compare_password($cred['salt'],$cred['hash'],$arg['password']);
- $res['response'] = $msg;
- if($verified)
- {
- Session::set('email',$cred['email']);
- Session::set('type',$cred['type']);
- Session::set('user_id',$cred['id']);
- Session::set('username',$cred['username']);
- Session::set('su',$cred['su']);
- $res['response'] = 'Account verified';
- }
- $res['success'] = $verified;
- }
- return $res;
- }
- // REST API Returned
- {"success":true,"response":"Account verified"}��������������������������������������������������������������������������������������������������������������������������������������������������������������
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement