|
|
|
@ -19,6 +19,7 @@ class AuthController extends Controller
|
|
|
|
|
{ |
|
|
|
|
$username = $request->username; |
|
|
|
|
$password = $request->password; |
|
|
|
|
$remember = $request->remember; |
|
|
|
|
$is_mobile = $request->is_mobile; |
|
|
|
|
|
|
|
|
|
if(empty($username) || empty($password)){ |
|
|
|
@ -46,6 +47,7 @@ class AuthController extends Controller
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$dataRole = Role::find($user->role_id); |
|
|
|
|
|
|
|
|
|
if($dataRole){ |
|
|
|
@ -57,18 +59,21 @@ class AuthController extends Controller
|
|
|
|
|
return response()->json(['error' => 'Unauthorized'], 401); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $this->respondWithToken($token, $user); |
|
|
|
|
return $this->respondWithToken($token, $user, $remember); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected function respondWithToken($token, $user) |
|
|
|
|
protected function respondWithToken($token, $user, $remember) |
|
|
|
|
{ |
|
|
|
|
$ttl = 60; |
|
|
|
|
if($remember) |
|
|
|
|
$ttl = 10080; |
|
|
|
|
return response()->json([ |
|
|
|
|
'code' => 200, |
|
|
|
|
'data' => array( |
|
|
|
|
'data_user' => $user, |
|
|
|
|
'access_token' => $token, |
|
|
|
|
'token_type' => 'bearer', |
|
|
|
|
'expires_in' => auth()->factory()->getTTL() * 360 |
|
|
|
|
'expires_in' => auth()->factory()->getTTL() * $ttl, |
|
|
|
|
), |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|