Advertisement
Guest User

authSlim.php

a guest
Mar 31st, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. //login user
  2. $app->post('/auth/login/user', function($request, $response, $args){
  3.     $input = $request->getParsedBody();
  4.     $auth = new CBTUser;
  5.     $status = '';
  6.  
  7.     $rand = rand(0,1000);
  8.    
  9.     $tokens = md5($rand);
  10.     $password = md5($input['password']);
  11.  
  12.     $username = CBTUser::where('Username', '=', $input['username'])->where('Password','=',$password)->first();
  13.  
  14.     //verifikasi jika username/password benar
  15.     if ($username->Username == $input['username']) {
  16.             $auth::where('Username', '=', $input['username'])->update(array('token' => $tokens));
  17.  
  18.             return $this->response->withJson(array('message' => 'oke redirect', 'status' => 'true', 'token' => $tokens));
  19.     }else{
  20.         return $this->response->withJson(array('message' => 'wrong password', 'status' => 'false'));
  21.     }
  22.     return $this->response->withJson(array('message' => 'your username not found', 'status' => 'false'));
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement