feat(auth): implement Google OAuth integration with user authentication and token exchange

This commit is contained in:
2026-07-22 13:43:14 -03:00
parent 855ac13990
commit 873855c85a
10 changed files with 272 additions and 2 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Domains\Auth\Controllers;
use App\Domains\Auth\Requests\GoogleTokenExchangeRequest;
use App\Domains\Auth\Resources\UserResource;
use App\Domains\Auth\Services\GoogleAuthService;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
class GoogleTokenExchangeController extends Controller
{
public function __construct(private readonly GoogleAuthService $googleAuthService) {}
public function __invoke(GoogleTokenExchangeRequest $request): JsonResponse
{
$authentication = $this->googleAuthService->exchange($request->validated('oauth_code'));
return response()->json([
'message' => 'Sesion iniciada correctamente.',
'token' => $authentication['token'],
'token_type' => 'Bearer',
'user' => UserResource::make($authentication['user']),
]);
}
}