36 lines
976 B
C#
36 lines
976 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Http;
|
|
using System;
|
|
using System.Web;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SecureCore.Controllers
|
|
{
|
|
[Route("[controller]")]
|
|
[ApiController]
|
|
public class AuthController : Controller
|
|
{
|
|
[HttpPost("login")]
|
|
[AcceptVerbs("POST")]
|
|
public IActionResult Login(LoginInfo info)
|
|
{
|
|
var (hash, salt) = Authentication.HashPassword(info.Password);
|
|
var options = new CookieOptions
|
|
{
|
|
Domain = "copyrightcrusader.org",
|
|
Expires = DateTime.Now.AddDays(7),
|
|
HttpOnly = true,
|
|
Secure = true,
|
|
Path = "/",
|
|
SameSite = SameSiteMode.Strict
|
|
};
|
|
|
|
HttpContext.Response.Cookies.Append("Session", Authentication.CreateSessionToken(), options);
|
|
|
|
return Ok();
|
|
}
|
|
}
|
|
}
|