Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api login consistency #46

Merged
merged 4 commits into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/Http/Controllers/Api/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@

class AuthController extends Controller
{

public function login(Request $request)
{
$request->validate([
'email' => 'required|string|email',
'password' => 'required|string|min:6',
nafiesl marked this conversation as resolved.
Show resolved Hide resolved
]);

$form = [
'grant_type' => 'password',
'client_id' => config('services.passport.client_id'),
Expand All @@ -32,6 +38,8 @@ public function logout()
$token->revoke();
});

return response()->json('Logged out successfully', 200);
return response()->json([
'message' => 'Logged out successfully',
], 200);
}
}
2 changes: 1 addition & 1 deletion routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// I think it's better without conflict the main project.

Route::post('auth/login', 'Api\Auth\AuthController@login')->name('api.auth.login');
Route::middleware('auth:api')->post('logout', 'Api\Auth\AuthController@logout')->name('api.auth.logout');
Route::middleware('auth:api')->post('auth/logout', 'Api\Auth\AuthController@logout')->name('api.auth.logout');

Route::group(['middleware' => 'auth:api', 'as' => 'api.', 'namespace' => 'Api'], function () {
/*
Expand Down