it ipimiutduioi
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
namespace GrossesMitainesAPI.Controllers;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using GrossesMitainesAPI.Data;
|
||||
using SignInResult = Microsoft.AspNetCore.Identity.SignInResult;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
|
||||
[EnableCors("_myAllowSpecificOrigins"), ApiController, Route("api"),
|
||||
Authorize(AuthenticationSchemes = "Identity.Application")]
|
||||
public class LoginController : Controller {
|
||||
//private readonly UserManager<InventoryUser> _userMan;
|
||||
private readonly SignInManager<InventoryUser> _signInMan;
|
||||
|
||||
public LoginController(SignInManager<InventoryUser> signin) {
|
||||
this._signInMan = signin;
|
||||
}
|
||||
|
||||
public class User {
|
||||
public string username { get; set; }
|
||||
public string password { get; set; }
|
||||
}
|
||||
|
||||
[HttpPost, Route("Login"), AllowAnonymous]
|
||||
public async Task<SignInResult> Login(User user, bool rememberMe = false) {
|
||||
return await _signInMan.PasswordSignInAsync(user.username, user.password, rememberMe, false);
|
||||
}
|
||||
|
||||
[HttpPost, Route("Logout")]
|
||||
public void Logout() { _signInMan.SignOutAsync(); }
|
||||
}
|
||||
|
Reference in New Issue
Block a user