added email too user

This commit is contained in:
Aldin296
2023-06-07 11:43:25 +02:00
parent 9b9844abb0
commit 5d33c5cd5c
3 changed files with 26 additions and 3 deletions
@@ -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;
}
}
@@ -52,6 +52,8 @@
<Small>Name: @context.Item.Name</Small>
<br />
<Small>Rolle: @context.Item.Role</Small>
<br />
<Small>E-Mail: @context.Item.Email</Small>
</Column>
</Row>
</Column>
@@ -77,6 +79,10 @@
<FieldLabel>User Name</FieldLabel>
<TextEdit Placeholder="Enter user name..." />
</Field>
<Field>
<FieldLabel>User E-Mail</FieldLabel>
<TextEdit Placeholder="Enter user E-mail..." />
</Field>
<Field>
<FieldLabel>User Password</FieldLabel>
<TextEdit Placeholder="Enter user password..." />
@@ -145,6 +151,18 @@
</Field>
<br />
<br />
<Field>
<FieldLabel>
<h5>
E-Mail
</h5>
<Paragraph>
Here you can change the E-Mail of a User
</Paragraph>
</FieldLabel>
<TextEdit Placeholder="Enter new email" />
</Field>
<br />
<Field>
<FieldLabel>
<h5>
@@ -189,7 +207,7 @@
</Div>
@code {
List<User> users = new List<User>() { 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<User> users = new List<User>() { new User("Silas", "aldjlfasd", "[email protected]", Role.Admin), new User("Joe", "qiowruioewjfopa", "[email protected]", Role.Admin), new User("Stefan", "adfadsdf", "[email protected]" , Role.Admin), new User("Manu", "öhöfldaösldf", "[email protected]", Role.User) };
User? SelectedUser = null;
User? UserCopy = null;
@@ -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();