Rename auth guard

This commit is contained in:
Pig Fang 2019-04-25 13:29:43 +08:00
parent d2ad6107d1
commit 1ae0329083
3 changed files with 11 additions and 11 deletions

View File

@ -254,9 +254,9 @@ class AuthController extends Controller
return view('auth.verify');
}
public function apiLogin(Request $request)
public function jwtLogin(Request $request)
{
$token = Auth::guard('api')->attempt([
$token = Auth::guard('jwt')->attempt([
'email' => $request->email,
'password' => $request->password
]);
@ -264,14 +264,14 @@ class AuthController extends Controller
return json(compact('token'));
}
public function apiLogout()
public function jwtLogout()
{
Auth::guard('api')->logout();
Auth::guard('jwt')->logout();
return response('', 204);
}
public function apiRefresh()
public function jwtRefresh()
{
return json(['token' => Auth::guard('api')->refresh()]);
return json(['token' => Auth::guard('jwt')->refresh()]);
}
}

View File

@ -41,7 +41,7 @@ return [
'provider' => 'users',
],
'api' => [
'jwt' => [
'driver' => 'jwt',
'provider' => 'users',
],

View File

@ -1,12 +1,12 @@
<?php
Route::prefix('auth')->group(function ($route) {
$route->post('login', 'AuthController@apiLogin');
$route->post('logout', 'AuthController@apiLogout')->middleware('auth.jwt');
$route->post('refresh', 'AuthController@apiRefresh')->middleware('auth.jwt');
$route->post('login', 'AuthController@jwtLogin');
$route->post('logout', 'AuthController@jwtLogout')->middleware('auth:jwt');
$route->post('refresh', 'AuthController@jwtRefresh')->middleware('auth:jwt');
});
Route::prefix('user')->middleware('auth:api')->group(function ($route) {
Route::prefix('user')->middleware('auth:jwt')->group(function ($route) {
$route->put('sign', 'UserController@sign');
$route->get('players', 'PlayerController@listAll');