Added some minor tweaks, and set up the EmployeeController to be usable by a frontend to see how well all this works so far.
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace SecureCore.Authentication
|
||||
{
|
||||
public static class SessionManager
|
||||
{
|
||||
private static int SessionKeySize { get; } = 64; //n bytes
|
||||
public static string SessionCookieName { get; } = "Session";
|
||||
|
||||
public static string CreateSessionToken()
|
||||
{
|
||||
@@ -32,6 +34,15 @@ namespace SecureCore.Authentication
|
||||
return Convert.ToBoolean(result);
|
||||
}
|
||||
|
||||
public static bool IsSessionTokenValid(HttpContext context)
|
||||
{
|
||||
AppSettingsManager.TryGetConnectionStringByName("MainDataConnectionString", out string connectionString);
|
||||
|
||||
if (!context.Request.Cookies.ContainsKey(SessionCookieName)) return false;
|
||||
|
||||
return IsSessionTokenValid(context.Request.Cookies[SessionCookieName], connectionString);
|
||||
}
|
||||
|
||||
public static void Logout(string sessionToken, string connectionString)
|
||||
{
|
||||
using var connection = new SqlConnection(connectionString);
|
||||
|
||||
Reference in New Issue
Block a user