Files
WebNovelPortal/WebNovelPortal/Controllers/AccountController.cs

35 lines
846 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace WebNovelPortal.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class AccountController : ControllerBase
{
[HttpGet]
[Route("login")]
public async Task Login(string redirect="/")
{
await HttpContext.ChallengeAsync(new AuthenticationProperties
{
RedirectUri = redirect
});
}
[HttpGet]
[Route("logout")]
public async Task Logout()
{
await HttpContext.SignOutAsync();
Response.Redirect("/");
}
}
}