diff options
Diffstat (limited to 'Services/UserService.cs')
| -rw-r--r-- | Services/UserService.cs | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/Services/UserService.cs b/Services/UserService.cs index d2abea3..db62553 100644 --- a/Services/UserService.cs +++ b/Services/UserService.cs @@ -1,9 +1,17 @@ -namespace HyperBooru.Services; +using Microsoft.AspNetCore.Authentication; +using System.Runtime.InteropServices; +using System.Security.Claims; +using System.Security.Principal; + +namespace HyperBooru.Services; public interface IUserService { public bool ShowNsfw { get; set; } public event EventHandler<bool> ShowNsfwChanged; + + public bool Login(string username, string password); + public void Logout(); } public class UserService : IUserService { @@ -18,4 +26,36 @@ public class UserService : IUserService { public event EventHandler<bool> ShowNsfwChanged; private bool showNsfw = false; + + private IGlobalUserService globalUserService; + private IHttpContextAccessor httpContextAccessor; + + public UserService( + IGlobalUserService globalUserService, + IHttpContextAccessor httpContextAccessor) { + + this.globalUserService = globalUserService; + this.httpContextAccessor = httpContextAccessor; + } + + public bool Login(string username, string password) { + var claims = new Claim[] { + }; + + var claimsIdentity = new ClaimsIdentity(claims); + + var claimsPrincipal = new ClaimsPrincipal(claimsIdentity); + + if(httpContextAccessor.HttpContext is null) + return false; + + httpContextAccessor.HttpContext.SignInAsync(claimsPrincipal) + .GetAwaiter() + .GetResult(); + + return true; + } + + public void Logout() { + } } |
