Skip to content

Commit

Permalink
Upgrade to .NET 8 and latest .NET 8 template
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Nov 17, 2023
1 parent 736b294 commit 228b43d
Show file tree
Hide file tree
Showing 70 changed files with 4,677 additions and 758 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using TalentBlazor.ServiceModel;

namespace TalentBlazor.Data;

public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : IdentityDbContext<ApplicationUser>(options)
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: IdentityDbContext<ApplicationUser>(options)
{
}
}
42 changes: 42 additions & 0 deletions TalentBlazor.ServiceInterface/Data/CustomUserSession.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
using ServiceStack;
using ServiceStack.Web;

namespace TalentBlazor.Data;

public class CustomUserSession : AuthUserSession
{
public override void PopulateFromClaims(IRequest httpReq, ClaimsPrincipal principal)
{
// Populate Session with data from Identity Auth Claims
ProfileUrl = principal.FindFirstValue(JwtClaimTypes.Picture);
}
}

/// <summary>
/// Add additional claims to the Identity Auth Cookie
/// </summary>
public class AdditionalUserClaimsPrincipalFactory(
UserManager<ApplicationUser> userManager,
RoleManager<IdentityRole> roleManager,
IOptions<IdentityOptions> optionsAccessor)
: UserClaimsPrincipalFactory<ApplicationUser,IdentityRole>(userManager, roleManager, optionsAccessor)
{
public override async Task<ClaimsPrincipal> CreateAsync(ApplicationUser user)
{
var principal = await base.CreateAsync(user);
var identity = (ClaimsIdentity)principal.Identity!;

var claims = new List<Claim>();
// Add additional claims here
if (user.ProfileUrl != null)
{
claims.Add(new Claim(JwtClaimTypes.Picture, user.ProfileUrl));
}

identity.AddClaims(claims);
return principal;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.*" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.*" />
<PackageReference Include="ServiceStack" Version="8.*" />
<PackageReference Include="ServiceStack.Ormlite" Version="8.*" />
<PackageReference Include="ServiceStack.Server" Version="8.*" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.Identity;
using TalentBlazor.ServiceModel;

namespace TalentBlazor.ServiceModel;
namespace TalentBlazor.Data;

[Icon(Svg = Icons.AppUser)]
[Alias("AspNetUsers")]
Expand All @@ -21,4 +22,3 @@ public class ApplicationUser : IdentityUser
[Input(Type = "file"), UploadTo("users")]
public string? ProfileUrl { get; set; }
}

1 change: 1 addition & 0 deletions TalentBlazor.ServiceModel/Talent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using ServiceStack.DataAnnotations;
using System;
using System.Collections.Generic;
using TalentBlazor.Data;

namespace TalentBlazor.ServiceModel;

Expand Down
8 changes: 1 addition & 7 deletions TalentBlazor.ServiceModel/TalentBlazor.ServiceModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.*" />
<PackageReference Include="ServiceStack.Interfaces" Version="8.*" />
</ItemGroup>

Expand All @@ -19,10 +19,4 @@
<Folder Include="Types\" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.Extensions.Identity.Stores">
<HintPath>..\..\..\..\..\Program Files\dotnet\shared\Microsoft.AspNetCore.App\8.0.0-rc.2.23480.2\Microsoft.Extensions.Identity.Stores.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion TalentBlazor/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<Routes />
<script src="_framework/blazor.web.js"></script>
<script src="js/servicestack-blazor.js"></script>
<script>JS.init()</script>
<script>JS.init({colorScheme:false})</script>
<script src="lib/js/highlight.js"></script>
<script>hljs.highlightAll()</script>
</body>
Expand Down
8 changes: 4 additions & 4 deletions TalentBlazor/Components/Identity/ExternalLoginPicker.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
{
<div>
<p>
There are no external authentication services configured.
See this <a class="@Css.Link" href="https://go.microsoft.com/fwlink/?LinkID=532715">article
about setting up this ASP.NET application to support logging in via external services</a>.
There are no external authentication services configured.
See this <HyperLink href="https://go.microsoft.com/fwlink/?LinkID=532715">article
about setting up this ASP.NET application to support logging in via external services</HyperLink>.
</p>
</div>
}
Expand All @@ -26,7 +26,7 @@ else
<div class="space-x-2">
@foreach (var provider in _externalLogins!)
{
<button type="submit" class="@Css.SecondaryButton" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
<button type="submit" class="@SecondaryButton.Classes" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion TalentBlazor/Components/Identity/LogoutForm.razor
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
if (SignInManager.IsSignedIn(user))
{
await SignInManager.SignOutAsync();
RedirectManager.RedirectTo(ReturnUrl ?? "/");
RedirectManager.RedirectTo(ReturnUrl ?? "/Account/Logout");
}
}
}
2 changes: 1 addition & 1 deletion TalentBlazor/Components/Identity/ShowRecoveryCodes.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h3 class="@Css.H3">Recovery codes</h3>
<Heading3>Recovery codes</Heading3>
<div class="max-w-xl">
<StatusMessage Message="@StatusMessage" />

Expand Down
9 changes: 5 additions & 4 deletions TalentBlazor/Components/Layout/ManageLayout.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@inherits LayoutComponentBase
@layout MainLayout

<h1 class="@Css.H1">Manage your account</h1>

<div>
<h4 class="font-semibold text-lg my-2">Change your account settings</h4>
<hr class="dark:border-gray-700" />
<div class="mt-8 mx-auto max-w-screen-lg">
<Heading1>Manage your account</Heading1>
<Heading4>Change your account settings</Heading4>
<hr class="mt-4 dark:border-gray-700" />
<div class="flex flex-wrap">
<div class="grow-0">
<ManageNavMenu />
Expand All @@ -15,3 +15,4 @@
</div>
</div>
</div>

10 changes: 6 additions & 4 deletions TalentBlazor/Components/Pages/Account/AccessDenied.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

<PageTitle>Access Denied</PageTitle>

<h1 class="text-3xl font-bold tracking-tight sm:text-4xl text-danger">Access Denied</h1>
<div class="mt-8 mx-auto max-w-lg">
<h1 class="text-3xl font-bold tracking-tight sm:text-4xl text-danger">Access Denied</h1>

<p class="my-4 text-danger">
You do not have access to this resource.
</p>
<p class="my-4 text-danger">
You do not have access to this resource.
</p>
</div>

@code {
[Parameter] public string ReturnUrl { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions TalentBlazor/Components/Pages/Account/ConfirmEmail.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/Account/ConfirmEmail"
@page "/Account/ConfirmEmail"

@using System.Text
@using Microsoft.AspNetCore.Identity
Expand All @@ -11,9 +11,9 @@

<PageTitle>Confirm email</PageTitle>

<h1 class="mb-3 @Css.H1">Confirm email</h1>
<div class="mt-8 mx-auto max-w-lg">
<Heading1>Confirm email</Heading1>

<div class="max-w-xl">
<StatusMessage Message="@statusMessage" />
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/Account/ConfirmEmailChange"
@page "/Account/ConfirmEmailChange"

@using System.Text
@using Microsoft.AspNetCore.Identity
Expand All @@ -13,9 +13,9 @@

<PageTitle>Confirm email change</PageTitle>

<h1 class="mb-3 @Css.H1">Confirm email change</h1>
<Heading1>Confirm email change</Heading1>

<div class="max-w-xl">
<div class="mt-8 mx-auto max-w-lg">
<StatusMessage Message="@_message" />
</div>

Expand Down
16 changes: 8 additions & 8 deletions TalentBlazor/Components/Pages/Account/ExternalLogin.razor
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
<PageTitle>Register</PageTitle>

<div class="mt-8 mx-auto max-w-lg">
<StatusMessage Message="@_message" />
<h1 class="@Css.H1">Register</h1>
<h2 class="@Css.H2" id="external-login-title">Associate your @providerDisplayName account.</h2>
<StatusMessage class="mb-3" Message="@_message" />
<Heading1>Register</Heading1>
<Heading2 id="external-login-title">Associate your @providerDisplayName account.</Heading2>

<Alert id="external-login-description" Type="AlertType.Information" class="my-4">
You've successfully authenticated with <strong>@providerDisplayName</strong>.
Expand All @@ -39,18 +39,18 @@
<div class="px-4 bg-white dark:bg-black sm:p-6">
<EditForm id="confirmation-form" Model="Input" OnValidSubmit="OnValidSubmitAsync" FormName="confirmation" method="post">
<DataAnnotationsValidator />
<ValidationSummary class="@Css.ValidationSummary" />
<ValidationSummary class="mb-3 text-danger text-center font-semibold" />

<div class="flex flex-col gap-4">
<div>
<label for="email" class="@Css.InputLabel">Email</label>
<label for="email" class="@TextInput.LabelClasses">Email</label>
<div class="mt-1 relative rounded-md shadow-sm">
<InputText id="email" type="text" @bind-Value="Input.Email" class="@Css.InputText" autocomplete="email" placeholder="Please enter your email." />
<InputText id="email" type="text" @bind-Value="Input.Email" class="@TextInput.InputClasses" autocomplete="email" placeholder="Please enter your email." />
</div>
<ValidationMessage For="() => Input.Email" class="@Css.ValidationMessage" />
<ValidationMessage For="() => Input.Email" class="mt-2 text-danger text-sm" />
</div>
<div>
<button type="submit" class="@Css.PrimaryButton">Register</button>
<PrimaryButton type="submit">Register</PrimaryButton>
</div>
</div>
</EditForm>
Expand Down
18 changes: 9 additions & 9 deletions TalentBlazor/Components/Pages/Account/ForgotPassword.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/Account/ForgotPassword"
@page "/Account/ForgotPassword"

@using System.ComponentModel.DataAnnotations
@using System.Text
Expand All @@ -16,23 +16,23 @@

<PageTitle>Forgot your password?</PageTitle>

<div class="max-w-xl">
<h1 class="mb-3 @Css.H1">Forgot your password?</h1>
<h3 class="@Css.H3">Enter your email.</h3>
<div class="mt-8 mx-auto max-w-lg">
<Heading1>Forgot your password?</Heading1>
<Heading3>Enter your email.</Heading3>

<EditForm Model="Input" FormName="forgot-password" OnValidSubmit="OnValidSubmitAsync" method="post">
<DataAnnotationsValidator />
<ValidationSummary class="@Css.ValidationSummary" />
<ValidationSummary class="mb-3 text-danger text-center font-semibold" />
<div class="flex flex-col gap-y-4">
<div>
<label for="email" class="@Css.InputLabel">Email</label>
<label for="email" class="@TextInput.LabelClasses">Email</label>
<div class="mt-1 relative rounded-md shadow-sm">
<InputText id="email" type="text" @bind-Value="Input.Email" class="@Css.InputText" autocomplete="username" aria-required="true" placeholder="[email protected]" />
<InputText id="email" type="text" @bind-Value="Input.Email" class="@TextInput.InputClasses" autocomplete="username" aria-required="true" placeholder="[email protected]" />
</div>
<ValidationMessage For="() => Input.Email" class="@Css.ValidationMessage" />
<ValidationMessage For="() => Input.Email" class="mt-2 text-danger text-sm" />
</div>
<div>
<button type="submit" class="@Css.PrimaryButton">Reset password</button>
<PrimaryButton type="submit">Reset password</PrimaryButton>
</div>
</div>
</EditForm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

<PageTitle>Forgot password confirmation</PageTitle>

<h1 class="@Css.H1">Forgot password confirmation</h1>
<div class="mt-8 mx-auto max-w-lg">
<Heading1>Forgot password confirmation</Heading1>

<p class="my-4">
Please check your email to reset your password.
</p>
</div>

<p class="my-4">
Please check your email to reset your password.
</p>
12 changes: 8 additions & 4 deletions TalentBlazor/Components/Pages/Account/InvalidPasswordReset.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

<PageTitle>Invalid password reset</PageTitle>

<h1 class="@Css.H1">Invalid password reset</h1>
<div class="mt-8 mx-auto max-w-lg">

<p class="my-4">
The password reset link is invalid.
</p>
<Heading1>Invalid password reset</Heading1>

<p class="my-4">
The password reset link is invalid.
</p>

</div>
10 changes: 7 additions & 3 deletions TalentBlazor/Components/Pages/Account/InvalidUser.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

<PageTitle>Invalid user</PageTitle>

<h3 class="@Css.H3">Invalid user</h3>
<div class="mt-8 mx-auto max-w-lg">

<Heading3>Invalid user</Heading3>

<div class="max-w-xl">
<StatusMessage />
</div>

<div class="max-w-xl">
<StatusMessage />
</div>
13 changes: 9 additions & 4 deletions TalentBlazor/Components/Pages/Account/Lockout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

<PageTitle>Locked out</PageTitle>

<header>
<h1 class="@Css.H1">Locked out</h1>
<p class="my-4 text-danger">This account has been locked out, please try again later.</p>
</header>
<div class="mt-8 mx-auto max-w-lg">

<header>
<Heading1>Locked out</Heading1>
<p class="my-4 text-danger">This account has been locked out, please try again later.</p>
</header>

</div>

Loading

0 comments on commit 228b43d

Please sign in to comment.