blackbirdchess-server/app/Http/Controllers/Auth/AuthenticatedSessionController.php

31 lines
735 B
PHP
Raw Normal View History

2023-02-01 17:10:21 +01:00
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\LoginRequest;
2023-08-16 15:14:19 +02:00
use App\Models\User;
2023-02-01 17:10:21 +01:00
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
2023-02-18 15:40:16 +01:00
use Illuminate\Support\Facades\Cache;
2023-02-01 17:10:21 +01:00
class AuthenticatedSessionController extends Controller
{
/**
* Handle an incoming authentication request.
*/
public function store(LoginRequest $request): JsonResponse
{
$request->authenticate();
$authid = uuid_create();
2023-02-18 15:40:16 +01:00
Cache::set('BBC-' . $authid, ['User' => $request->user()]);
2023-02-01 17:10:21 +01:00
return response()->json(['Success' => true, 'Authorization' => $authid]);
}
2023-08-16 15:14:19 +02:00
2023-02-01 17:10:21 +01:00
}