KTV/app/Http/Controllers/AuthController.php

64 lines
1.7 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
use OpenApi\Annotations as OA;
/**
* @OA\Tag(
* name="Auth",
* description="用戶註冊、登入、登出與個人資料"
* )
*/
class AuthController extends Controller
{
/**
* @OA\Get(
* path="/api/profile",
* summary="Get current user profile",
* tags={"Auth"},
* security={{"Authorization":{}}},
* @OA\Response(
* response=200,
* description="User profile",
* @OA\JsonContent(
* allOf={
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
* @OA\Property(property="data", ref="#/components/schemas/User")
* )
* }
* )
* ),
* @OA\Response(
* response=401,
* description="Unauthorized",
* @OA\JsonContent(
* allOf={
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
* @OA\Property(property="code", type="string", example="UNAUTHORIZED"),
* @OA\Property(property="message", type="string", example="Unauthorized"),
* @OA\Property(property="data", type="null")
* )
* }
* )
* ),
* @OA\Parameter(
* name="Accept",
* in="header",
* required=true,
* @OA\Schema(type="string", default="application/json")
* )
* )
*/
public function profile(Request $request)
{
return response()->json($request->user());
}
}