Implement base controller for shared functionality; update existing controllers to inherit from BaseController and adjust user ID handling. Add JWT authentication support and modify item retrieval methods in GameDataController.
This commit is contained in:
13
Controllers/BaseController.cs
Normal file
13
Controllers/BaseController.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace PetCompanion.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/v1/[controller]")]
|
||||
public class BaseController : Controller
|
||||
{
|
||||
protected string userId => User.Claims.FirstOrDefault(c => c.Type == "user_id").Value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user