summaryrefslogtreecommitdiff
path: root/Logics/DestroyUserAccountSessionLogic.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Logics/DestroyUserAccountSessionLogic.cs')
-rw-r--r--Logics/DestroyUserAccountSessionLogic.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/Logics/DestroyUserAccountSessionLogic.cs b/Logics/DestroyUserAccountSessionLogic.cs
new file mode 100644
index 0000000..1e5a5f5
--- /dev/null
+++ b/Logics/DestroyUserAccountSessionLogic.cs
@@ -0,0 +1,30 @@
+using Microsoft.AspNetCore.Identity;
+using BackendPIA.Services;
+using BackendPIA.Models;
+using BackendPIA.Forms;
+
+namespace BackendPIA.Logics {
+ public class DestroyUserAccountSessionLogic {
+ private readonly UserManager<UserAccount> _manager;
+ private readonly string _email;
+
+ public DestroyUserAccountSessionLogic(UserManager<UserAccount> manager, string email) {
+ _manager = manager;
+ _email = email;
+ }
+
+ public async Task<bool> Call() {
+ var user = await _manager.FindByEmailAsync(_email);
+
+ if(user == null)
+ return false;
+
+ user.SessionToken = null;
+ user.CurrentToken = null;
+ user.SessionTokenExpiryTime = null;
+ await _manager.UpdateAsync(user);
+
+ return true;
+ }
+ }
+} \ No newline at end of file