-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fixed api endpoint that creates admin user in IdentityEndpoints.cs …
…& UserService.cs - fixed method that call onboarding endpoints in frontend in ApiService.cs - removed default functionality to create seed users in DatabaseInitializer.cs - created another way to send notifications in NotificationService.cs - finished onboarding in general - updated project ProjectConstants.cs
- Loading branch information
Showing
15 changed files
with
294 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,47 +39,5 @@ public static async Task InitializeAsync(IServiceScope scope) | |
} | ||
} | ||
|
||
// User Creation | ||
foreach (var user in seedUsers) | ||
{ | ||
var hashed = password.HashPassword(user, "password123"); | ||
user.PasswordHash = hashed; | ||
await userStore.CreateAsync(user); | ||
|
||
if (user.Email is not null) | ||
{ | ||
var appUser = await userManager.FindByEmailAsync(user.Email); | ||
|
||
if (appUser is not null && user.RoleList is not null) | ||
{ | ||
await userManager.AddToRolesAsync(appUser, user.RoleList); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
private class SeedUser : AppUser | ||
{ | ||
public string[]? RoleList { get; set; } | ||
} | ||
private static readonly IEnumerable<SeedUser> seedUsers = | ||
[ | ||
new SeedUser() | ||
{ | ||
Email = "[email protected]", | ||
NormalizedEmail = "[email protected]", | ||
NormalizedUserName = "[email protected]", | ||
RoleList = [ "Admin", "User" ], | ||
UserName = "[email protected]" | ||
}, | ||
new SeedUser() | ||
{ | ||
Email = "[email protected]", | ||
NormalizedEmail = "[email protected]", | ||
NormalizedUserName = "[email protected]", | ||
RoleList = [ "User" ], | ||
UserName = "[email protected]" | ||
}, | ||
]; | ||
} |
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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
<div class="w-3/5 bg-primary-content h-full"> | ||
<div class="w-5/6 mx-auto flex flex-col items-center justify-center h-full"> | ||
<h1 class="text-primary title-text mt-8 mb-8">Wardrobe Manager</h1> | ||
<img class="rounded-lg max-w-[32rem]" src="img/home-background.jpg" /> | ||
<img class="rounded-lg max-w-[32rem]" src="@ProjectConstants.HomeBackgroundImage" /> | ||
</div> | ||
</div> | ||
|
||
|
@@ -13,12 +13,12 @@ | |
<h2 class="pt-8 heading-text text-primary-content">@PageHeaderText</h2> | ||
<EditForm class="pt-8 w-full pb-8" Model="@formModel" OnSubmit="SubmitButtonMethod"> | ||
<p class="text-primary-content py-2 subtitle-text">Email</p> | ||
<InputText @bind-Value="@formModel.email" required class=" w-full subtitle-text input input-bordered px-6 py-10 text-primary bg-primary-content mb-4 rounded-2xl" placeholder="Your Username Here" type="email"/> | ||
<InputText @bind-Value="@formModel.email" required class=" w-full subtitle-text input input-bordered px-6 py-10 text-primary bg-primary-content mb-4 rounded-2xl" placeholder="@("[email protected]")" type="email"/> | ||
|
||
<p class="text-primary-content py-2 subtitle-text">Password</p> | ||
<InputText @bind-Value="@formModel.password" required class="subtitle-text w-full input input-bordered px-6 py-10 text-primary bg-primary-content mb-8 rounded-2xl" placeholder="............" type="password"/> | ||
|
||
<input class="w-full py-4 subtitle-text bg-secondary text-secondary-content rounded-2xl " type="submit" value="@SubmitButtonText"/> | ||
<input class="btn btn-secondary btn-wide w-full subtitle-text rounded-2xl " type="submit" value="@SubmitButtonText"/> | ||
</EditForm> | ||
|
||
<div class="flex flex-row items-center gap-3 mb-8"> | ||
|
14 changes: 14 additions & 0 deletions
14
WardrobeManager.Presentation/Components/Onboarding/OnboardingSection.razor
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,14 @@ | ||
@namespace WardrobeManager.Presentation.Components.Onboarding | ||
|
||
<div class="grow w-full flex flex-col items-center gap-5 justify-evenly"> | ||
<h3 class="subheading-text text-primary">@Title</h3> | ||
@ChildContent | ||
<button @onclick="ButtonClickCallback" class="btn btn-accent btn-wide subtitle-text">@ButtonText</button> | ||
</div> | ||
|
||
@code { | ||
[Parameter] public required string Title { get; set; } | ||
[Parameter] public required RenderFragment ChildContent { get; set; } | ||
[Parameter] public required string ButtonText { get; set; } | ||
[Parameter] public required EventCallback ButtonClickCallback { get; set; } | ||
} |
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
105 changes: 105 additions & 0 deletions
105
WardrobeManager.Presentation/Pages/Public/Onboarding.razor
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,105 @@ | ||
@page "/onboarding" | ||
|
||
@using System.ComponentModel.DataAnnotations | ||
@using WardrobeManager.Presentation.Components.Onboarding | ||
@using WardrobeManager.Presentation.Components.FormItems | ||
@namespace WardrobeManager.Presentation.Pages.Public | ||
|
||
<PageTitle>Onboarding - WardrobeManager</PageTitle> | ||
|
||
|
||
<div class="h-full flex flex-col items-center bg-primary-content gap-10"> | ||
<h3 class="heading-text">Welcome to WardrobeManager!</h3> | ||
|
||
<div class="grow flex "> | ||
@switch (currentSectionIndex) | ||
{ | ||
case 0: | ||
{ | ||
<OnboardingSection Title="@($"{ProjectConstants.ProjectName} is an all-in-one solution to clothing management.")" | ||
ButtonText="Next" | ||
ButtonClickCallback="GoToNextSection"> | ||
<img src="@ProjectConstants.HomeBackgroundImage" class="h-96 object-contain rounded-2xl"/> | ||
</OnboardingSection> | ||
break; | ||
} | ||
case 1: | ||
{ | ||
<OnboardingSection Title="@($"Enter the credentials for the administrator account")" | ||
ButtonText="Next" | ||
ButtonClickCallback="CreateAdminUser"> | ||
<div> | ||
<LabelAndElement Label="Username" Orientation="vertical"> | ||
<InputText @bind-Value="email" required class="bg-base-200 text-base-content p-3 rounded-xl" placeholder="@("[email protected]")" type="email"/> | ||
</LabelAndElement> | ||
<LabelAndElement Label="Password" Orientation="vertical"> | ||
<InputText @bind-Value="password" required class="bg-base-200 text-base-content p-3 rounded-xl" placeholder="............" type="password"/> | ||
</LabelAndElement> | ||
|
||
|
||
</div> | ||
</OnboardingSection> | ||
break; | ||
} | ||
case 2: | ||
{ | ||
<OnboardingSection Title="@($"Enjoy using {ProjectConstants.ProjectName}!")" | ||
ButtonText="Go To Dashboard" | ||
ButtonClickCallback="@(() => _navManager.NavigateTo("/dashboard"))"> | ||
<p class="subtitle-text"> | ||
If you encounter any issues, please open an issue on the <a href="@ProjectConstants.ProjectGitRepo" class="text-accent">GitHub repo</a> | ||
</p> | ||
</OnboardingSection> | ||
break; | ||
} | ||
} | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
@code { | ||
private int currentSectionIndex = 0; | ||
|
||
private string email = string.Empty; | ||
private string password = string.Empty; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
var exists = await _apiService.DoesAdminUserExist(); | ||
if (exists) | ||
{ | ||
_navManager.NavigateTo("/login"); | ||
} | ||
|
||
await base.OnInitializedAsync(); | ||
} | ||
|
||
public void GoToNextSection() | ||
{ | ||
currentSectionIndex++; | ||
StateHasChanged(); | ||
} | ||
|
||
public async Task CreateAdminUser() | ||
{ | ||
if (email == string.Empty || password == string.Empty) | ||
{ | ||
_notificationService.AddNotification("You must specify a username and password!", NotificationType.Warning); | ||
} | ||
|
||
var credentials = new AdminUserCredentials | ||
{ | ||
email = email, password = password | ||
}; | ||
var res = await _apiService.CreateAdminUserIfMissing(credentials); | ||
_notificationService.AddNotification(res.Item2); | ||
|
||
// If added the admin user was sucessful | ||
if (res.Item1 is true) | ||
{ | ||
GoToNextSection(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.