70 lines
1.5 KiB
C#
70 lines
1.5 KiB
C#
|
|
using Microsoft.AspNetCore.Authorization;
|
||
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using System;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using zero.Core;
|
||
|
|
using zero.Core.Api;
|
||
|
|
using zero.Core.Entities;
|
||
|
|
|
||
|
|
namespace zero.Web.Controllers
|
||
|
|
{
|
||
|
|
[AllowAnonymous]
|
||
|
|
public class AuthenticationController : BackofficeController
|
||
|
|
{
|
||
|
|
private IAuthenticationApi Api { get; set; }
|
||
|
|
|
||
|
|
public AuthenticationController(IZeroConfiguration config, IAuthenticationApi api) : base(config)
|
||
|
|
{
|
||
|
|
Api = api;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Get the currently logged in user
|
||
|
|
/// </summary>
|
||
|
|
[AllowAnonymous]
|
||
|
|
//[Authorize()]
|
||
|
|
public async Task<IActionResult> GetUser()
|
||
|
|
{
|
||
|
|
return Json(await Api.GetUser());
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Tries a login for a user with username/password
|
||
|
|
/// </summary>
|
||
|
|
[HttpPost, AllowAnonymous]
|
||
|
|
public async Task<IActionResult> LoginUser()
|
||
|
|
{
|
||
|
|
throw new NotImplementedException();
|
||
|
|
//User user = await Api.Login(model.Username, model.Password, model.RememberMe);
|
||
|
|
|
||
|
|
//if (user == null)
|
||
|
|
//{
|
||
|
|
// return AsError("Username or password is incorrect");
|
||
|
|
//}
|
||
|
|
|
||
|
|
//await Api.SetLastSeen(user);
|
||
|
|
|
||
|
|
//return Json(new
|
||
|
|
//{
|
||
|
|
// IsSuccess = true,
|
||
|
|
// User = new Results.User(user),
|
||
|
|
// UserMap = await Api.GetUserMap()
|
||
|
|
//});
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Logout for the current user
|
||
|
|
/// </summary>
|
||
|
|
[HttpPost]
|
||
|
|
public async Task<IActionResult> LogoutUser()
|
||
|
|
{
|
||
|
|
throw new NotImplementedException();
|
||
|
|
//await Api.Logout();
|
||
|
|
//return AsSuccess();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|