mirror of
https://github.com/robonen/education-project.git
synced 2026-03-20 02:44:31 +00:00
общий код
This commit is contained in:
24
app/Http/Controllers/Auth/LoginController.php
Normal file
24
app/Http/Controllers/Auth/LoginController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Auth\LoginRequest;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
public function __invoke(LoginRequest $request)
|
||||
{
|
||||
$credentials = $request->only('login', 'password');
|
||||
|
||||
if (auth()->attempt($credentials))
|
||||
return response()->json('You cannot sign with those credentials!', 401);
|
||||
|
||||
$token = auth()->user()->makeToken($request->get('remember_me'));
|
||||
|
||||
return response()->json([
|
||||
'token_type' => 'Bearer',
|
||||
'token' => $token->accessToken,
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user