Passwort setzen funktion
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
@page "/login"
|
||||
@using FoodsharingSiegen.Server.Auth
|
||||
@using FoodsharingSiegen.Shared.Helper
|
||||
@layout LoginLayout
|
||||
|
||||
@inject AuthService AuthService
|
||||
@@ -9,11 +10,11 @@
|
||||
<div class="card" style="width: 100%; max-width: 380px;">
|
||||
<div class="card-header">FS Siegen</div>
|
||||
<div class="card-body">
|
||||
<Validation Validator="ValidateMail" @bind-Status="@IsValidMail">
|
||||
<Validation Validator="ValidationHelper.ValidateMail" @bind-Status="@IsValidMail">
|
||||
<TextEdit @bind-Text="Mailaddress" Role="TextRole.Email" Placeholder="E-Mail" Class="mt-0" KeyUp="TextEdit_KeyUp"></TextEdit>
|
||||
</Validation>
|
||||
|
||||
<Validation Validator="ValidatePassword" @bind-Status="@IsValidPassword">
|
||||
<Validation Validator="ValidationHelper.ValidatePassword" @bind-Status="@IsValidPassword">
|
||||
<TextEdit @bind-Text="Password" Role="TextRole.Password" Placeholder="Passwort" Class="my-3" KeyUp="TextEdit_KeyUp"></TextEdit>
|
||||
</Validation>
|
||||
|
||||
|
||||
@@ -74,50 +74,5 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method ValidateMail
|
||||
|
||||
/// <summary>
|
||||
/// Validates the mail using the specified args (a. beging, 11.04.2022)
|
||||
/// </summary>
|
||||
/// <param name="args">The args</param>
|
||||
private void ValidateMail(ValidatorEventArgs args)
|
||||
{
|
||||
var email = Convert.ToString(args.Value);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(email))
|
||||
{
|
||||
args.Status = ValidationStatus.None;
|
||||
return;
|
||||
}
|
||||
|
||||
var isMatch = Regex.IsMatch(email, "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", RegexOptions.IgnoreCase);
|
||||
|
||||
args.Status = isMatch ? ValidationStatus.Success : ValidationStatus.Error;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method ValidatePassword
|
||||
|
||||
/// <summary>
|
||||
/// Validates the password using the specified args (a. beging, 11.04.2022)
|
||||
/// </summary>
|
||||
/// <param name="args">The args</param>
|
||||
private void ValidatePassword(ValidatorEventArgs args)
|
||||
{
|
||||
var password = Convert.ToString(args.Value);
|
||||
if (string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
args.Status = ValidationStatus.None;
|
||||
return;
|
||||
}
|
||||
|
||||
var isValid = password.Length > 3;
|
||||
|
||||
args.Status = isValid ? ValidationStatus.Success : ValidationStatus.Error;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
@page "/user"
|
||||
@page "/users"
|
||||
@using FoodsharingSiegen.Contracts.Entity
|
||||
@using FoodsharingSiegen.Server.Dialogs
|
||||
|
||||
@inherits FoodsharingSiegen.Server.BaseClasses.FsBase
|
||||
|
||||
@@ -26,7 +27,7 @@
|
||||
<h2>Benutzerverwaltung <span style="font-size: .5em; line-height: 0;">Admin</span></h2>
|
||||
|
||||
<div class="my-2">
|
||||
<Button Color="Color.Primary" Disabled="@(SelectedUser == null)"><i class="fa-solid fa-key"></i> setzen</Button>
|
||||
<Button Color="Color.Primary" Disabled="@(SelectedUser == null)" Clicked="() => PasswordModal.Show(SelectedUser!)"><i class="fa-solid fa-key"></i> setzen</Button>
|
||||
</div>
|
||||
|
||||
<DataGrid TItem="User"
|
||||
@@ -108,4 +109,6 @@
|
||||
</DisplayTemplate>
|
||||
</DataGridColumn>
|
||||
</DataGridColumns>
|
||||
</DataGrid>
|
||||
</DataGrid>
|
||||
|
||||
<SetPasswordModal @ref="PasswordModal" OnPasswortSet="OnPasswordSet"></SetPasswordModal>
|
||||
@@ -1,6 +1,7 @@
|
||||
using Blazorise.DataGrid;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using FoodsharingSiegen.Server.Dialogs;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Pages
|
||||
@@ -44,6 +45,7 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
public List<Company> Companies { get; set; }
|
||||
public List<UserGroup> SelectedCompanies { get; set; }
|
||||
public List<string> SelectedCompanyTexts { get; set; } = new();
|
||||
public SetPasswordModal PasswordModal { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -147,6 +149,11 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private async Task OnPasswordSet(User user)
|
||||
{
|
||||
var result = await UserService.SetPassword(user);
|
||||
}
|
||||
}
|
||||
|
||||
public class Company
|
||||
|
||||
Reference in New Issue
Block a user