zero authorize

This commit is contained in:
2020-04-15 14:09:52 +02:00
parent 9f5d9bb920
commit ccc63b9602
23 changed files with 389 additions and 97 deletions
+25 -11
View File
@@ -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
});
}
}
}