-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed SyncAuthUserChange + updated Example1
- Loading branch information
Showing
25 changed files
with
242 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
Example1.RazorPages.IndividualAccounts/Pages/AuthUsers/ListUsers.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
@page | ||
@model ListUsersModel | ||
|
||
<h1>Auth users</h1> | ||
|
||
@if (!string.IsNullOrEmpty(Model.Message)) | ||
{ | ||
<h3 class="text-primary">@Model.Message</h3> | ||
} | ||
|
||
<a class="btn btn-primary" asp-area="" asp-page=".\SyncUsers">Sync with authentication provider's users</a> | ||
<p></p> | ||
|
||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th> | ||
UserName | ||
</th> | ||
<th> | ||
</th> | ||
<th> | ||
AuthRoles | ||
</th> | ||
<th> | ||
Edit | Delete | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var item in @Model.AuthUserList) | ||
{ | ||
<tr> | ||
<td> | ||
@Html.DisplayFor(modelItem => item.UserName) | ||
</td> | ||
<td> | ||
@Html.DisplayFor(modelItem => item.Email) | ||
</td> | ||
<td> | ||
@string.Join(", ", item.RoleNames) | ||
</td> | ||
<td> | ||
<a asp-area="" asp-page="AuthUsers\Edit" asp-route-id="@item.UserId">Edit</a> | ||
| | ||
<a asp-area="" asp-page="AuthUsers\Delete" asp-route-id="@item.UserId">Delete</a> | ||
</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
|
||
|
||
|
||
@section Scripts{ | ||
|
||
|
||
<script type='text/javascript'> | ||
$(function () { | ||
$('[data-toggle="tooltip"]').tooltip(); | ||
}) | ||
</script> | ||
} | ||
|
30 changes: 30 additions & 0 deletions
30
Example1.RazorPages.IndividualAccounts/Pages/AuthUsers/ListUsers.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using AuthPermissions.AdminCode; | ||
using ExamplesCommonCode.CommonAdmin; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Example1.RazorPages.IndividualAccounts.Pages.AuthUsers | ||
{ | ||
public class ListUsersModel : PageModel | ||
{ | ||
private readonly IAuthUsersAdminService _authUsersAdmin; | ||
|
||
public ListUsersModel(IAuthUsersAdminService authUsersAdmin) | ||
{ | ||
_authUsersAdmin = authUsersAdmin; | ||
} | ||
|
||
public List<AuthUserDisplay> AuthUserList { get; private set; } | ||
public string Message { get; set; } | ||
|
||
public async Task OnGet(string message) | ||
{ | ||
Message = message; | ||
var userQuery = _authUsersAdmin.QueryAuthUsers(); | ||
AuthUserList = await AuthUserDisplay.SelectQuery(userQuery.OrderBy(x => x.Email)).ToListAsync(); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
Example1.RazorPages.IndividualAccounts/Pages/AuthUsers/SyncUsers.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@page | ||
@using global::AuthPermissions.AdminCode | ||
@model Example1.RazorPages.IndividualAccounts.Pages.AuthUsers.SyncUsersModel | ||
|
||
@if (!@Model.Data.Any()) | ||
{ | ||
<h3>There are no changes to apply to the AuthUsers</h3> | ||
return; | ||
} | ||
|
||
<h3>Changes needed based on authentication provider's users</h3> | ||
<form method="post"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Change type</th> | ||
<th>Email</th> | ||
<th>UserName</th> | ||
<th>Roles Count</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@for (int i = 0; i < Model.Data.Count; i++) | ||
{ | ||
<tr> | ||
<td> | ||
@Model.Data[i].FoundChangeType | ||
@Html.Hidden($"Data[{i}].{nameof(SyncAuthUserWithChange.UserId)}", Model.Data[i].UserId) | ||
@Html.Hidden($"Data[{i}].{nameof(SyncAuthUserWithChange.FoundChangeType)}", Model.Data[i].FoundChangeType) | ||
</td> | ||
|
||
<td @(Model.Data[i].EmailChanged ? "class=bg-warning text-dark" : "")> | ||
@Model.Data[i].Email | ||
@Html.Hidden($"Data[{i}].{nameof(SyncAuthUserWithChange.Email)}", Model.Data[i].Email) | ||
</td> | ||
<td @(Model.Data[i].UserNameChanged ? "class=bg-warning text-dark" : "")> | ||
@Model.Data[i].UserName | ||
@Html.Hidden($"Data[{i}].{nameof(SyncAuthUserWithChange.UserName)}", Model.Data[i].UserName) | ||
</td> | ||
<td>@Model.Data[i].NumRoles</td> | ||
</tr> | ||
} | ||
|
||
</tbody> | ||
</table> | ||
|
||
<button class="btn btn-primary">Apply Sync Changes</button> | ||
|
||
</form> | ||
|
33 changes: 33 additions & 0 deletions
33
Example1.RazorPages.IndividualAccounts/Pages/AuthUsers/SyncUsers.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using AuthPermissions.AdminCode; | ||
using AuthPermissions.CommonCode; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace Example1.RazorPages.IndividualAccounts.Pages.AuthUsers | ||
{ | ||
public class SyncUsersModel : PageModel | ||
{ | ||
private readonly IAuthUsersAdminService _authUsersAdmin; | ||
|
||
public SyncUsersModel(IAuthUsersAdminService authUsersAdmin) | ||
{ | ||
_authUsersAdmin = authUsersAdmin; | ||
} | ||
|
||
[BindProperty] | ||
public List<SyncAuthUserWithChange> Data { get; set; } | ||
|
||
public async Task OnGet() | ||
{ | ||
Data = await _authUsersAdmin.SyncAndShowChangesAsync(); | ||
} | ||
|
||
public async Task<IActionResult> OnPost() | ||
{ | ||
var status = await _authUsersAdmin.ApplySyncChangesAsync(Data); | ||
return RedirectToPage("ListUsers", new { message = status.Message }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
3 changes: 1 addition & 2 deletions
3
...vidualAccounts/Pages/UserClaims.cshtml.cs → ...ounts/Pages/UserInfo/UserClaims.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.