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] [Required]
public string PasswordHash { get; private set; } public string PasswordHash { get; private set; }
[Required]
public string Email { get; set; }
[Required] [Required]
public Role Role { get; set; } public Role Role { get; set; }
public string? SessionToken { 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; Name = name;
PasswordHash = passwordHash; PasswordHash = passwordHash;
Email = email;
Role = role; Role = role;
} }
} }
@@ -52,6 +52,8 @@
<Small>Name: @context.Item.Name</Small> <Small>Name: @context.Item.Name</Small>
<br /> <br />
<Small>Rolle: @context.Item.Role</Small> <Small>Rolle: @context.Item.Role</Small>
<br />
<Small>E-Mail: @context.Item.Email</Small>
</Column> </Column>
</Row> </Row>
</Column> </Column>
@@ -77,6 +79,10 @@
<FieldLabel>User Name</FieldLabel> <FieldLabel>User Name</FieldLabel>
<TextEdit Placeholder="Enter user name..." /> <TextEdit Placeholder="Enter user name..." />
</Field> </Field>
<Field>
<FieldLabel>User E-Mail</FieldLabel>
<TextEdit Placeholder="Enter user E-mail..." />
</Field>
<Field> <Field>
<FieldLabel>User Password</FieldLabel> <FieldLabel>User Password</FieldLabel>
<TextEdit Placeholder="Enter user password..." /> <TextEdit Placeholder="Enter user password..." />
@@ -145,6 +151,18 @@
</Field> </Field>
<br /> <br />
<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> <Field>
<FieldLabel> <FieldLabel>
<h5> <h5>
@@ -189,7 +207,7 @@
</Div> </Div>
@code { @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? SelectedUser = null;
User? UserCopy = null; User? UserCopy = null;
@@ -120,7 +120,7 @@ public class AuthenticationService : IAuthenticationService
return Result.Fail("User name already exists!"); 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); _ = mainDatabaseContext.Users.Add(user);
return (await Result.Try(() => mainDatabaseContext.SaveChangesAsync())).ToResult(); return (await Result.Try(() => mainDatabaseContext.SaveChangesAsync())).ToResult();