Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //login user
- $app->post('/auth/login/user', function($request, $response, $args){
- $input = $request->getParsedBody();
- $auth = new CBTUser;
- $status = '';
- $rand = rand(0,1000);
- $tokens = md5($rand);
- $password = md5($input['password']);
- $username = CBTUser::where('Username', '=', $input['username'])->where('Password','=',$password)->first();
- //verifikasi jika username/password benar
- if ($username->Username == $input['username']) {
- $auth::where('Username', '=', $input['username'])->update(array('token' => $tokens));
- return $this->response->withJson(array('message' => 'oke redirect', 'status' => 'true', 'token' => $tokens));
- }else{
- return $this->response->withJson(array('message' => 'wrong password', 'status' => 'false'));
- }
- return $this->response->withJson(array('message' => 'your username not found', 'status' => 'false'));
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement