Update nach User-Passwort-Change

This commit is contained in:
2021-07-15 10:30:16 +02:00
parent 93e3957702
commit 1ff218a129
93 changed files with 7399 additions and 1071 deletions

View File

@@ -0,0 +1,240 @@
@page "/Admin/AspNetUsers/AspNetUserRolleList"
@inject Blazored.SessionStorage.ISessionStorageService sessionStorage
@using Microsoft.AspNetCore.Authorization;
@using Microsoft.AspNetCore.Identity;
@inject UserManager<IdentityUser> _UserManager
@inject RoleManager<IdentityRole> _RoleManager
@inherits ListBase
@using Syncfusion.Blazor.Grids;
@using Syncfusion.Blazor.Buttons;
@using Syncfusion.Blazor.Spinner;
@using Syncfusion.Blazor.Popups;
@using BlazorApp.Helper
@using BWPMModels;
@using BlazorApp.Controller;
<h1>AspNetUserRolle</h1>
<div class="col-lg-12 control-section">
<div class="content-wrapper">
<div class="row">
<SfGrid DataSource="@GridData" @ref="Grid" AllowPaging="true" AllowSelection="true" AllowSorting="true" Toolbar="@(new List<string>() { "Add", "Edit", "Update", "Cancel", "Passwort ändern" })">
<GridPageSettings PageCount="5" PageSizes="true"></GridPageSettings>
<GridEditSettings AllowAdding="false" AllowDeleting="false" AllowEditing="true" Mode="EditMode.Normal"></GridEditSettings>
<GridEvents RowSelected="GetSelectedRecords" OnActionBegin="OnBeginHandler" OnActionComplete="OnCompletedHandler" TValue="BWPMModels.AspNetUserRolle" OnToolbarClick="ToolBarClickHandler" OnDataBound="RowDataBoundHandler"></GridEvents>
<GridSelectionSettings EnableToggle="true" Type="Syncfusion.Blazor.Grids.SelectionType.Single"></GridSelectionSettings>
<GridColumns>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.Id) HeaderText="Id" IsPrimaryKey="true" AllowAdding="false" Width="60"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.UserName) HeaderText="Username" AllowEditing="false" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.NormalizedUserName) HeaderText="Normalizedusername" AllowEditing="false" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.Email) HeaderText="Email" Width="100" AllowEditing="false" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.NormalizedEmail) HeaderText="Normalizedemail" Width="100" AllowEditing="false" Visible="false"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.EmailConfirmed) HeaderText="Emailconfirmed" Width="100" AllowEditing="false" Visible="true" DisplayAsCheckBox="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.PasswordHash) HeaderText="Passwordhash" Width="100" AllowEditing="false" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.SecurityStamp) HeaderText="Securitystamp" Width="100" AllowEditing="false" Visible="false"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.ConcurrencyStamp) HeaderText="Concurrencystamp" Width="100" AllowEditing="false" Visible="false"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.PhoneNumber) HeaderText="Phonenumber" Width="100" AllowEditing="false" Visible="false"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.PhoneNumberConfirmed) HeaderText="Phonenumberconfirmed" Width="100" Visible="false" DisplayAsCheckBox="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.TwoFactorEnabled) HeaderText="Twofactorenabled" Width="100" Visible="true" DisplayAsCheckBox="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.LockoutEnabled) HeaderText="Lockoutenabled" Width="100" Visible="true" DisplayAsCheckBox="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.AccessFailedCount) HeaderText="Accessfailedcount" Width="100" Visible="false"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUserRolle.RoleId) HeaderText="Roleid" Width="100" Visible="false">
<GridForeignColumn Field=@nameof(BWPMModels.AspNetUserRolle.RoleId) HeaderText="Rolle" ForeignKeyValue=@nameof(BWPMModels.AspNetRoles.Name) ForeignKeyField=@nameof(BWPMModels.AspNetRoles.Id) ForeignDataSource="@AspNetRoles" Width="150"></GridForeignColumn>
</GridColumn>
</GridColumns>
</SfGrid>
</div>
</div>
</div>
<SfDialog Width="400px" IsModal="true" @bind-Visible="@IsVisible">
<DialogEvents OnOverlayClick="@OnOverlayclick">
</DialogEvents>
<DialogTemplates>
<Header>Passwort-Änderung für @Username</Header>
<Content>
<label style="color:red">@ErrorMsg</label>
<label>
Neues Passwort:
<input type="password" @bind-value="newpassword" id="password" name="Required" class="e-input">
Passwort-Bestätigung
<input type="password" @bind-value="newpassword1" id="password1" name="Required" class="e-input">
</label>
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="OK" IsPrimary="true" OnClick="@SavePasswort" />
<DialogButton Content="Abbruch" OnClick="@CloseDialog" />
</DialogButtons>
</SfDialog>
@code{
private bool IsVisible { get; set; } = false;
private string Gridid = "";
public List<BWPMModels.AspNetUserRolle> Temp { get; set; }
private string newpassword { get; set; } = "";
private string newpassword1 { get; set; } = "";
private string ErrorMsg { get; set; } = "";
private string Username { get; set; } = "";
SfGrid<BWPMModels.AspNetUserRolle> Grid { get; set; }
private void OnOverlayclick(MouseEventArgs arg)
{
this.IsVisible = false;
}
private void ShowDialog()
{
this.ErrorMsg = "";
this.IsVisible = true; ;
}
private void CloseDialog()
{
this.IsVisible = false; ;
}
private void SavePasswort()
{
if (newpassword != newpassword1)
{
this.ErrorMsg = "Passworte stimmen nicht überein.";
}
else
{
IdentityUser objUser = new IdentityUser();
objUser.Id = Gridid;
var user = _UserManager.FindByIdAsync(Gridid);
var password = _UserManager.PasswordHasher.HashPassword(objUser,newpassword);
BWPMModels.AspNetUsers usr = new BWPMModels.AspNetUsers();
usr.Id = Gridid;
usr.PasswordHash = password;
BlazorApp.Controller.AspNetUserRolleController.savepassword(usr);
this.IsVisible = false;
}
}
public async Task ToolBarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if (args.Item.Text == "Passwort ändern")
{
var temp = await this.Grid.GetSelectedRecords(); // return the details of selceted record
if (temp != null)
{
Username = temp[0].UserName;
Gridid = temp[0].Id;
ShowDialog();
}
}
}
public async Task GetSelectedRecords(RowSelectEventArgs<BWPMModels.AspNetUserRolle> args)
{
}
public List<BWPMModels.AspNetUserRolle> GridData { get; set; }
public List<BWPMModels.AspNetUserRolle> AspNetUserRolles { get; set; }
public List<BWPMModels.AspNetRoles> AspNetRoles { get; set; }
string userid = "";
public static int? pkey { get; set; }
public bool Initial { get; set; } = true;
public bool ContinuePaging = true;
public bool InitialRender { get; set; }
public int Value = 0; // consider that value your querystring contains
public int foundrow = 0;
protected override void OnInitialized()
{
/// GridData = OrdersDetails.GetAllRecords();
GridData = BlazorApp.Controller.AspNetUserRolleController.GetAllData();
AspNetRoles = BlazorApp.Controller.AspNetRolesController.GetAllData();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
userid = await sessionStorage.GetItemAsync<string>("UserID");
if (userid == null)
{
var authState = await authenticationStateTask;
var userId = authState.User.Claims.FirstOrDefault().Value;
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
await sessionStorage.SetItemAsync("UserID", userId);
}
else
{
await sessionStorage.SetItemAsync("UserID", userId);
}
}
}
private async Task OnBeginHandler(ActionEventArgs<BWPMModels.AspNetUserRolle> Args)
{
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
if (Args.Action == "Add")
{
}
else
{
AspNetUserRoles rolle = new AspNetUserRoles();
rolle.RoleId = Args.Data.RoleId;
rolle.UserId = Args.Data.Id;
BlazorApp.Controller.AspNetUserRolesController.savedata(rolle);
}
}
}
public async Task OnCompletedHandler(ActionEventArgs<BWPMModels.AspNetUserRolle> Args)
{
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
}
}
public async void RowDataBoundHandler(BeforeDataBoundArgs<BWPMModels.AspNetUserRolle> args)
{
if (!Initial)
{
//await Task.Delay(100);
//var Idx = await this.Grid.GetRowIndexByPrimaryKey(Convert.ToDouble(Value)); //get index value
//this.Grid.SelectRow(Convert.ToDouble(Idx));
}
Initial = false;
}
}

View File

@@ -0,0 +1,175 @@
@page "/Admin/AspNetUsers/AspNetUsersList"
@inject Blazored.SessionStorage.ISessionStorageService sessionStorage
@inherits ListBase
@using Syncfusion.Blazor.Grids;
@using Syncfusion.Blazor.Buttons;
@using Syncfusion.Blazor.Spinner;
@using BlazorApp.Helper
@using BWPMModels;
@using BlazorApp.Controller;
<h1>AspNetUsers</h1>
<div class="col-lg-12 control-section">
<div class="content-wrapper">
<div class="row">
<SfGrid DataSource="@GridData" @ref="Grid" AllowPaging="true" AllowSorting="true" Toolbar="@(new List<string>() { "Add", "Edit", "Update", "Cancel" })">
<GridPageSettings PageCount="5" PageSizes="true"></GridPageSettings>
<GridEditSettings AllowAdding="true" AllowDeleting="false" AllowEditing="true" Mode="EditMode.Dialog"></GridEditSettings>
@*<GridEvents OnActionBegin="OnBeginHandler" OnActionComplete="OnCompletedHandler" TValue="AspNetUsers" OnDataBound="RowDataBoundHandler"></GridEvents>*@
<GridColumns>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.Id) HeaderText="Id" IsPrimaryKey="true" AllowAdding="false" Width="60"></GridColumn><GridColumn Field=@nameof(BWPMModels.AspNetUsers.Id) HeaderText="Id" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.UserName) HeaderText="Username" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.NormalizedUserName) HeaderText="Normalizedusername" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.Email) HeaderText="Email" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.NormalizedEmail) HeaderText="Normalizedemail" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.EmailConfirmed) HeaderText="Emailconfirmed" Width="100" Visible="true" DisplayAsCheckBox="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.PasswordHash) HeaderText="Passwordhash" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.SecurityStamp) HeaderText="Securitystamp" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.ConcurrencyStamp) HeaderText="Concurrencystamp" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.PhoneNumber) HeaderText="Phonenumber" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.PhoneNumberConfirmed) HeaderText="Phonenumberconfirmed" Width="100" Visible="true" DisplayAsCheckBox="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.TwoFactorEnabled) HeaderText="Twofactorenabled" Width="100" Visible="true" DisplayAsCheckBox="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.LockoutEnabled) HeaderText="Lockoutenabled" Width="100" Visible="true" DisplayAsCheckBox="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.AccessFailedCount) HeaderText="Accessfailedcount" Width="100" Visible="true"></GridColumn>
</GridColumns>
</SfGrid>
</div>
</div>
</div>
@code{ SfGrid<BWPMModels.AspNetUsers> Grid { get; set; }
public List<BWPMModels.AspNetUsers> GridData { get; set; }
public List<BWPMModels.AspNetUsers> AspNetUserss { get; set; }
string userid = "";
public static int? pkey { get; set; }
public bool Initial { get; set; } = true;
public bool ContinuePaging = true;
public bool InitialRender { get; set; }
public string Value = ""; // consider that value your querystring contains
public int foundrow = 0;
protected override void OnInitialized()
{
/// GridData = OrdersDetails.GetAllRecords();
GridData = BlazorApp.Controller.AspNetUsersController.GetAllData();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
userid = await sessionStorage.GetItemAsync<string>("UserID");
if (userid == null)
{
var authState = await authenticationStateTask;
var userId = authState.User.Claims.FirstOrDefault().Value;
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
await sessionStorage.SetItemAsync("UserID", userId);
}
else
{
await sessionStorage.SetItemAsync("UserID", userId);
}
}
}
private async Task OnBeginHandler(ActionEventArgs<BWPMModels.AspNetUsers> Args)
{
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
if (Args.Action == "Add")
{
//Args.Data.Id = BlazorApp.Controller.AspNetUsersController.InsertData(Args.Data);
//Value = Args.Data.ID;
}
else
{
BlazorApp.Controller.AspNetUsersController.savedata(Args.Data);
}
}
}
public async Task OnCompletedHandler(ActionEventArgs<BWPMModels.AspNetUsers> Args)
{
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
await Grid.SetRowData(Args.Data.Id, Args.Data);
double xx = 0;
Value = Args.Data.Id;
xx = await DataHandler();
await Grid.SelectRow(xx);
}
}
public async void RowDataBoundHandler(BeforeDataBoundArgs<BWPMModels.AspNetUsers> args)
{
if (!Initial)
{
//await Task.Delay(100);
//var Idx = await this.Grid.GetRowIndexByPrimaryKey(Convert.ToDouble(Value)); //get index value
//this.Grid.SelectRow(Convert.ToDouble(Idx));
}
Initial = false;
}
public async Task<double> DataHandler()
{
var PageCount = (GridData.Count / Grid.PageSettings.PageSize) + 1;
ContinuePaging = true;
var CurrentPage = 1;
Grid.Refresh();
await Grid.GoToPage(1);
for (int i = 1; i <= PageCount; i++)
{
List<BWPMModels.AspNetUsers> Rows = await Grid.GetCurrentViewRecords(); // returns the current view data
for (int j = 0; j < Grid.PageSettings.PageSize; j++)
{
if (j < Rows.Count && Rows[j].Id == Value)
{
foundrow = j;
ContinuePaging = false; // prevent the default navigation
break;
}
}
if (ContinuePaging)
{
if (i >= PageCount)
{
i = 0;
}
await Grid.GoToPage(i + 1);
}
else
{
return foundrow;
}
}
return foundrow;
} }

View File

@@ -0,0 +1,142 @@
@page "/Admin/AspNetUsers/UserRollen"
@inject Blazored.SessionStorage.ISessionStorageService sessionStorage
@inherits ListBase
@using Syncfusion.Blazor.Grids;
@using Syncfusion.Blazor.Buttons;
@using Syncfusion.Blazor.Spinner;
@using BlazorApp.Helper
@using BWPMModels;
@using BlazorApp.Controller;
<h1>AspNetRoles</h1>
<div class="col-lg-12 control-section">
<div class="content-wrapper">
<div class="row">
<div class="col-6">
<SfGrid ID="GridUser" DataSource="@GridDataUser" AllowPaging="true" AllowSorting="true" AllowRowDragAndDrop="true">
<GridPageSettings PageCount="5" PageSizes="true"></GridPageSettings>
@*<GridEditSettings AllowAdding="true" AllowDeleting="false" AllowEditing="true" Mode="EditMode.Dialog"></GridEditSettings>*@
@*<GridEvents OnActionBegin="OnBeginHandler" OnActionComplete="OnCompletedHandler" TValue="BWPMModels.AspNetUsers" OnDataBound="RowDataBoundHandler"></GridEvents>*@
<GridRowDropSettings TargetID="GridRolle"></GridRowDropSettings>
<GridColumns>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.Id) HeaderText="Id" IsPrimaryKey="true" AllowAdding="false" Width="60" Visible="false"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.UserName) HeaderText="Name" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(BWPMModels.AspNetUsers.Email) HeaderText="Name" Width="100" Visible="true"></GridColumn>
</GridColumns>
</SfGrid>
</div>
<div class="col-6">
<SfGrid ID="GridRolle" DataSource="@GridData" @ref="Grid" AllowPaging="true" AllowSorting="true" AllowRowDragAndDrop="true">
<GridPageSettings PageCount="5" PageSizes="true"></GridPageSettings>
@*<GridEditSettings AllowAdding="true" AllowDeleting="false" AllowEditing="true" Mode="EditMode.Dialog"></GridEditSettings>*@
<GridEvents OnActionBegin="OnBeginHandler" OnActionComplete="OnCompletedHandler" TValue="AspNetRoles" OnDataBound="RowDataBoundHandler"></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(AspNetRoles.Id) HeaderText="Id" IsPrimaryKey="true" AllowAdding="false" Width="60" Visible="false"></GridColumn>
<GridColumn Field=@nameof(AspNetRoles.Name) HeaderText="Name" Width="100" Visible="true"></GridColumn>
<GridColumn Field=@nameof(AspNetRoles.NormalizedName) HeaderText="Normalizedname" Width="100" Visible="false"></GridColumn>
<GridColumn Field=@nameof(AspNetRoles.ConcurrencyStamp) HeaderText="Concurrencystamp" Width="100" Visible="false"></GridColumn>
</GridColumns>
</SfGrid>
</div>
</div>
</div>
</div>
@code{
SfGrid<AspNetRoles> Grid { get; set; }
public List<BWPMModels.AspNetRoles> GridData { get; set; }
public List<BWPMModels.AspNetRoles> AspNetRoless { get; set; }
public List<BWPMModels.AspNetUsers> GridDataUser { get; set; }
public List<BWPMModels.AspNetUsers> AspNetUsers { get; set; }
string userid = "";
public static int? pkey { get; set; }
public bool Initial { get; set; } = true;
public bool ContinuePaging = true;
public bool InitialRender { get; set; }
public int Value = 0; // consider that value your querystring contains
public int foundrow = 0;
protected override void OnInitialized()
{
/// GridData = OrdersDetails.GetAllRecords();
GridData = BlazorApp.Controller.AspNetRolesController.GetAllData();
GridDataUser = BlazorApp.Controller.AspNetUsersController.GetAllData();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
userid = await sessionStorage.GetItemAsync<string>("UserID");
if (userid == null)
{
var authState = await authenticationStateTask;
var userId = authState.User.Claims.FirstOrDefault().Value;
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
await sessionStorage.SetItemAsync("UserID", userId);
}
else
{
await sessionStorage.SetItemAsync("UserID", userId);
}
}
}
private async Task OnBeginHandler(ActionEventArgs<BWPMModels.AspNetRoles> Args)
{
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
if (Args.Action == "Add")
{
}
else
{
BlazorApp.Controller.AspNetRolesController.savedata(Args.Data);
}
}
}
public async Task OnCompletedHandler(ActionEventArgs<BWPMModels.AspNetRoles> Args)
{
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
}
}
public async void RowDataBoundHandler(BeforeDataBoundArgs<BWPMModels.AspNetRoles> args)
{
if (!Initial)
{
//await Task.Delay(100);
//var Idx = await this.Grid.GetRowIndexByPrimaryKey(Convert.ToDouble(Value)); //get index value
//this.Grid.SelectRow(Convert.ToDouble(Idx));
}
Initial = false;
}
}