Skip to content

Commit 5f4da42

Browse files
authored
Merge pull request #6 from Lan2Play/feature/AuthRework
Rework auth
2 parents 40499e7 + 21eea00 commit 5f4da42

93 files changed

Lines changed: 716 additions & 2333 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NetEvent/Client/Models/User.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

NetEvent/Client/NetEvent.Client.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,4 @@
2828
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
2929
</ItemGroup>
3030

31-
<ItemGroup>
32-
<Folder Include="Models\" />
33-
</ItemGroup>
34-
3531
</Project>

NetEvent/Client/Pages/Administration/Index.razor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Microsoft.AspNetCore.Components;
2-
using NetEvent.Shared.Models;
2+
using NetEvent.Shared.Dto;
33

44
namespace NetEvent.Client.Pages.Administration
55
{
@@ -9,11 +9,11 @@ public partial class Index
99
[Inject]
1010
public HttpClient HttpClient { get; set; }
1111

12-
public List<ApplicationUser>? Users { get; private set; }
12+
public List<CurrentUser>? Users { get; private set; }
1313

1414
protected override async Task OnInitializedAsync()
1515
{
16-
Users = await Utils.Get<List<ApplicationUser>>(HttpClient, "users");
16+
Users = await Utils.Get<List<CurrentUser>>(HttpClient, "users");
1717
}
1818

1919
}

NetEvent/Client/Pages/Administration/Settings.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@page "/administration/settings"
22
@using Microsoft.AspNetCore.Authorization
3-
@using NetEvent.Shared.Models;
3+
44

55
@attribute [Authorize(Roles = "Admin")]
66

NetEvent/Client/Pages/Administration/Settings.razor.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.AspNetCore.Components;
6-
using System.Net.Http;
7-
using System.Net.Http.Json;
8-
using Microsoft.AspNetCore.Components.Authorization;
9-
using Microsoft.AspNetCore.Components.Forms;
10-
using Microsoft.AspNetCore.Components.Routing;
11-
using Microsoft.AspNetCore.Components.Web;
12-
using Microsoft.AspNetCore.Components.Web.Virtualization;
13-
using Microsoft.AspNetCore.Components.WebAssembly.Http;
14-
using Microsoft.JSInterop;
15-
using NetEvent.Client;
16-
using NetEvent.Client.Shared;
17-
using MudBlazor;
18-
using NetEvent.Shared.Models;
192

203
namespace NetEvent.Client.Pages.Administration
214
{

NetEvent/Client/Pages/Administration/Users.razor

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
@page "/administration/users"
22
@using Microsoft.AspNetCore.Authorization
33
@using Microsoft.AspNetCore.Identity
4-
@using NetEvent.Shared.Models;
4+
@using NetEvent.Shared.Dto
5+
56

67
@attribute [Authorize(Roles = "Admin")]
78

89
<MudTabs Elevation="1" Rounded="true">
910
<MudTabPanel Text="User">
10-
<MudDataGrid T="ApplicationUser"
11+
<MudDataGrid T="CurrentUser"
1112
MultiSelection="false"
1213
Items="@AllUsers"
1314
Sortable="true"
@@ -26,27 +27,27 @@
2627
</ToolBarContent>
2728
<Columns>
2829
@*<SelectColumn T="ApplicationUser" />*@
29-
<Column T="ApplicationUser" Field="UserName" Title="Username" />
30-
<Column T="ApplicationUser" Field="FirstName" />
31-
<Column T="ApplicationUser" Field="LastName" />
32-
<Column T="ApplicationUser" Field="Email" />
33-
<Column T="ApplicationUser" Field="PhoneNumber" Title="Molar mass" />
34-
<Column T="ApplicationUser" Field="EmailConfirmed">
30+
<Column T="CurrentUser" Field="UserName" Title="Username" />
31+
<Column T="CurrentUser" Field="FirstName" />
32+
<Column T="CurrentUser" Field="LastName" />
33+
<Column T="CurrentUser" Field="Email" />
34+
<Column T="CurrentUser" Field="PhoneNumber" Title="Molar mass" />
35+
<Column T="CurrentUser" Field="EmailConfirmed">
3536
<CellTemplate>
3637
<MudCheckBox Checked="@context.Item.EmailConfirmed" ReadOnly="true" />
3738
</CellTemplate>
3839
<EditTemplate>
3940
<MudCheckBox @bind-Checked="@context.Item.EmailConfirmed" Label="Email confirmed" />
4041
</EditTemplate>
4142
</Column>
42-
<Column T="ApplicationUser" CellClass="d-flex justify-end">
43+
<Column T="CurrentUser" CellClass="d-flex justify-end">
4344
<CellTemplate>
4445
<MudIconButton Size="@Size.Small" Icon="@Icons.Outlined.Edit" OnClick="@context.Actions.StartEditingItem" />
4546
</CellTemplate>
4647
</Column>
4748
</Columns>
4849
<PagerContent>
49-
<MudDataGridPager T="ApplicationUser" />
50+
<MudDataGridPager T="CurrentUser" />
5051
</PagerContent>
5152
</MudDataGrid>
5253
</MudTabPanel>

NetEvent/Client/Pages/Administration/Users.razor.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.AspNetCore.Components;
6-
using System.Net.Http;
7-
using System.Net.Http.Json;
8-
using Microsoft.AspNetCore.Components.Authorization;
9-
using Microsoft.AspNetCore.Components.Forms;
10-
using Microsoft.AspNetCore.Components.Routing;
11-
using Microsoft.AspNetCore.Components.Web;
12-
using Microsoft.AspNetCore.Components.Web.Virtualization;
13-
using Microsoft.AspNetCore.Components.WebAssembly.Http;
14-
using Microsoft.JSInterop;
15-
using NetEvent.Client;
16-
using NetEvent.Client.Shared;
17-
using MudBlazor;
18-
using NetEvent.Shared.Models;
192
using Microsoft.AspNetCore.Identity;
3+
using NetEvent.Shared.Dto;
204

215
namespace NetEvent.Client.Pages.Administration
226
{
@@ -29,17 +13,17 @@ public partial class Users
2913

3014
protected override async Task OnInitializedAsync()
3115
{
32-
AllUsers = await Utils.Get<List<ApplicationUser>>(HttpClient, "users");
16+
AllUsers = await Utils.Get<List<CurrentUser>>(HttpClient, "users");
3317
AllRoles = await Utils.Get<List<IdentityRole>>(HttpClient, "roles");
3418
}
3519

3620
#region Users
3721

38-
public List<ApplicationUser>? AllUsers { get; private set; }
22+
public List<CurrentUser>? AllUsers { get; private set; }
3923
private string _usersSearchString;
4024

4125
// quick filter - filter gobally across multiple columns with the same input
42-
private Func<ApplicationUser, bool> _usersQuickFilter => x =>
26+
private Func<CurrentUser, bool> _usersQuickFilter => x =>
4327
{
4428
if (string.IsNullOrWhiteSpace(_usersSearchString))
4529
return true;
@@ -60,7 +44,7 @@ protected override async Task OnInitializedAsync()
6044
};
6145

6246

63-
void CommittedUserChanges(ApplicationUser item)
47+
void CommittedUserChanges(CurrentUser item)
6448
{
6549
_ = Utils.Put(HttpClient, $"users/{item.Id}", item);
6650
}

NetEvent/Client/Pages/Authentication.razor

Lines changed: 0 additions & 7 deletions
This file was deleted.

NetEvent/Client/Pages/Index.razor

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@
55
<h1>Hello, world!</h1>
66

77
Welcome to your new app.
8-
9-
<SurveyPrompt Title="How is Blazor working for you?" />

NetEvent/Client/Pages/Login.razor

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@page "/login"
2+
3+
<h3>Login</h3>
4+
5+
<EditForm Model="LoginRequest" OnValidSubmit="ExecuteLogin">
6+
<DataAnnotationsValidator />
7+
<MudCard >
8+
<MudCardContent>
9+
<MudTextField id="Input.Email" Label="Email" @bind-Value="LoginRequest.UserName" For="@(() => LoginRequest.UserName)" />
10+
<MudTextField id="Input.Password" Label="Password" @bind-Value="LoginRequest.Password" For="@(() => LoginRequest.Password)" InputType="InputType.Password" />
11+
<MudCheckBox id="Input.Remember" Label="Remember Me" @bind-Checked="LoginRequest.RememberMe" />
12+
</MudCardContent>
13+
<MudCardActions>
14+
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Outlined" Color="Color.Primary" Class="ma-2 py-2">Login</MudButton>
15+
</MudCardActions>
16+
</MudCard>
17+
</EditForm>

0 commit comments

Comments
 (0)