Update nach BlazorApp Berufe

This commit is contained in:
shu committed 2021-07-13 08:55:34 +02:00
1 parent a437ae0be4
commit 93e3957702
4853 files changed
+9820723 -2369

No files matched your search

@@ -0,0 +1,41 @@
using APP.Models;
using BWPMModels;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace APP.Helper
{
public class CustomClaimsPrincipal : UserClaimsPrincipalFactory<AppUser>
{
private readonly UserManager<AppUser> _userManger;
public CustomClaimsPrincipal(UserManager<AppUser> userManager, IOptions<IdentityOptions> optionsAccessor) : base(userManager, optionsAccessor)
{
_userManger = userManager;
}
public override async Task<ClaimsPrincipal> CreateAsync(AppUser user)
{
try
{
var principal = await base.CreateAsync(user);
((ClaimsIdentity)principal.Identity).AddClaims(new[]
{
new Claim("Id", user.Id.ToString()),
new Claim("Email", user.Email),
new Claim("DisplayName", user.FullName ?? user.Email),
new Claim("Avatar", user.Avatar ?? string.Empty),
});
return principal;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
@@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace APP.Helper
{
public class MyCookieAuthenticationEvents : CookieAuthenticationEvents
{
public override Task RedirectToLogin(RedirectContext<CookieAuthenticationOptions> context)
{
//context.RedirectUri = "/login?returnUrl=" + context.HttpContext.Request.Path.Value;
context.RedirectUri = "/";
return base.RedirectToLogin(context);
}
}
}