zero authorize
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
using zero.Core;
|
||||
@@ -23,15 +22,6 @@ namespace zero.Web.Controllers
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetUser()
|
||||
{
|
||||
return Json(new
|
||||
{
|
||||
user = HttpContext.User.Identity.IsAuthenticated
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Login([FromQuery] string username, [FromQuery] string password)
|
||||
{
|
||||
@@ -44,5 +34,29 @@ namespace zero.Web.Controllers
|
||||
result
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[ZeroAuthorize]
|
||||
public async Task<IActionResult> GetUser()
|
||||
{
|
||||
User user = await SignInManager.UserManager.GetUserAsync(HttpContext.User);
|
||||
|
||||
return Json(new
|
||||
{
|
||||
user
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Logout()
|
||||
{
|
||||
await SignInManager.SignOutAsync();
|
||||
|
||||
return Json(new
|
||||
{
|
||||
success = true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user