48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
namespace Webzine.WebApplication.Controllers
|
|
{
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
public class AccountController : Controller
|
|
{
|
|
[HttpGet("/account/login")]
|
|
public IActionResult Login(string? returnUrl = "/")
|
|
{
|
|
return this.Challenge(
|
|
new AuthenticationProperties
|
|
{
|
|
RedirectUri = string.IsNullOrWhiteSpace(returnUrl) ? "/" : returnUrl,
|
|
},
|
|
OpenIdConnectDefaults.AuthenticationScheme);
|
|
}
|
|
|
|
[HttpGet("/account/logout")]
|
|
public IActionResult Logout()
|
|
{
|
|
return this.SignOut(
|
|
new AuthenticationProperties
|
|
{
|
|
RedirectUri = "/",
|
|
},
|
|
CookieAuthenticationDefaults.AuthenticationScheme);
|
|
}
|
|
|
|
[HttpGet("/account/access-denied")]
|
|
public IActionResult AccessDenied()
|
|
{
|
|
return this.View();
|
|
}
|
|
|
|
[HttpGet("/account/auth-error")]
|
|
public IActionResult AuthError(string? message = null)
|
|
{
|
|
this.ViewData["Message"] = string.IsNullOrWhiteSpace(message)
|
|
? "Une erreur est survenue pendant la connexion."
|
|
: message;
|
|
|
|
return this.View();
|
|
}
|
|
}
|
|
} |