This commit is contained in:
@ -1,7 +1,9 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using HanyadikHetVan.Data.Entities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Net.Mime;
|
||||
using System.Security.Claims;
|
||||
|
||||
@ -12,9 +14,9 @@ namespace HanyadikHetVan.Controllers.V1
|
||||
[ApiController]
|
||||
public class TestController : Controller
|
||||
{
|
||||
private UserManager<IdentityUser> _userManager;
|
||||
private UserManager<User> _userManager;
|
||||
|
||||
public TestController(UserManager<IdentityUser> userManager)
|
||||
public TestController(UserManager<User> userManager)
|
||||
{
|
||||
_userManager = userManager ?? throw new ArgumentNullException(nameof(userManager));
|
||||
}
|
||||
@ -32,7 +34,7 @@ namespace HanyadikHetVan.Controllers.V1
|
||||
[Produces(MediaTypeNames.Application.Json)]
|
||||
public string Protected()
|
||||
{
|
||||
return this.User.FindFirst(ClaimTypes.NameIdentifier).Value;
|
||||
return this.User.FindFirst(ClaimTypes.Role).Value;
|
||||
}
|
||||
|
||||
[Authorize(Roles = "admin")]
|
||||
|
Reference in New Issue
Block a user