From 5d33c5cd5cca11e6b0e88c3d8b5cff732b2568c6 Mon Sep 17 00:00:00 2001
From: Aldin296 <99395958+Aldin296@users.noreply.github.com>
Date: Wed, 7 Jun 2023 11:43:25 +0200
Subject: [PATCH] added email too user
---
.../Elektrifikatsiya/Models/User.cs | 7 ++++++-
.../Elektrifikatsiya/Pages/Admin.razor | 20 ++++++++++++++++++-
.../Implementations/AuthenticationService.cs | 2 +-
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Models/User.cs b/src/Elektrifikatsiya/Elektrifikatsiya/Models/User.cs
index 72aaeb2..48ddf27 100644
--- a/src/Elektrifikatsiya/Elektrifikatsiya/Models/User.cs
+++ b/src/Elektrifikatsiya/Elektrifikatsiya/Models/User.cs
@@ -20,15 +20,20 @@ public class User
[Required]
public string PasswordHash { get; private set; }
+ [Required]
+ public string Email { get; set; }
+
[Required]
public Role Role { get; set; }
+
public string? SessionToken { get; set; }
- public User(string name, string passwordHash, Role role)
+ public User(string name, string passwordHash, string email, Role role)
{
Name = name;
PasswordHash = passwordHash;
+ Email = email;
Role = role;
}
}
\ No newline at end of file
diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Admin.razor b/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Admin.razor
index a0d6fe5..a92d666 100644
--- a/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Admin.razor
+++ b/src/Elektrifikatsiya/Elektrifikatsiya/Pages/Admin.razor
@@ -52,6 +52,8 @@
Name: @context.Item.Name
Rolle: @context.Item.Role
+
+ E-Mail: @context.Item.Email
@@ -77,6 +79,10 @@
User Name
+
+ User E-Mail
+
+
User Password
@@ -145,6 +151,18 @@
+
+
+
+ E-Mail
+
+
+ Here you can change the E-Mail of a User
+
+
+
+
+
@@ -189,7 +207,7 @@
@code {
- List users = new List() { new User("Silas", "aldjlfasd", Role.Admin), new User("Joe", "qiowruioewjfopa", Role.Admin), new User("Stefan", "adfadsdf", Role.Admin), new User("Manu", "öhöfldaösldf", Role.User) };
+ List users = new List() { new User("Silas", "aldjlfasd", "funny@gmail.com", Role.Admin), new User("Joe", "qiowruioewjfopa", "fluffmcfluff@hotmail.com", Role.Admin), new User("Stefan", "adfadsdf", "hahababaman@mail.com" , Role.Admin), new User("Manu", "öhöfldaösldf", "megatollermanu69@mail.com", Role.User) };
User? SelectedUser = null;
User? UserCopy = null;
diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Services/Implementations/AuthenticationService.cs b/src/Elektrifikatsiya/Elektrifikatsiya/Services/Implementations/AuthenticationService.cs
index 69b3ba9..a880860 100644
--- a/src/Elektrifikatsiya/Elektrifikatsiya/Services/Implementations/AuthenticationService.cs
+++ b/src/Elektrifikatsiya/Elektrifikatsiya/Services/Implementations/AuthenticationService.cs
@@ -120,7 +120,7 @@ public class AuthenticationService : IAuthenticationService
return Result.Fail("User name already exists!");
}
- User user = new User(name, BC.HashPassword(password), role);
+ User user = new User(name, BC.HashPassword(password), "", role);
_ = mainDatabaseContext.Users.Add(user);
return (await Result.Try(() => mainDatabaseContext.SaveChangesAsync())).ToResult();