U2 identity-mail-flows (backend): taal per gebruiker, uitnodigingsmail, opnieuw versturen, meldingen, stamp-controle
Kolommen Users.PreferredLanguage en Invitations.Language (additieve migratie). IdentityMailService verstuurt uitnodiging, nieuwe link en meldingen bij deactiveren, heractiveren en rolwijziging; een mailfout laat nooit een actie falen, het resultaat gaat mee in de respons naast de kopieerbare link. Nieuwe actie resend-invite. De security stamp zit in het access token en wordt vergeleken in de actief-controle: een wachtwoordwijziging beeindigt eerder uitgegeven access tokens, de refresh geeft stil een nieuw token. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,7 +39,11 @@ public class ApplicationDbContext : IdentityDbContext<ApplicationUser, Applicati
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
// Hernoemen van standaard Identity tabellen (NFR-ID-MAINT-01)
|
||||
builder.Entity<ApplicationUser>(entity => { entity.ToTable("Users"); });
|
||||
builder.Entity<ApplicationUser>(entity =>
|
||||
{
|
||||
entity.ToTable("Users");
|
||||
entity.Property(e => e.PreferredLanguage).HasMaxLength(8);
|
||||
});
|
||||
builder.Entity<ApplicationRole>(entity => { entity.ToTable("Roles"); });
|
||||
builder.Entity<IdentityUserRole<Guid>>(entity => { entity.ToTable("UserRoles"); });
|
||||
builder.Entity<IdentityUserClaim<Guid>>(entity => { entity.ToTable("UserClaims"); });
|
||||
@@ -74,6 +78,7 @@ public class ApplicationDbContext : IdentityDbContext<ApplicationUser, Applicati
|
||||
entity.HasIndex(e => e.Token).IsUnique();
|
||||
entity.Property(e => e.Token).IsRequired().HasMaxLength(256);
|
||||
entity.Property(e => e.Email).IsRequired().HasMaxLength(256);
|
||||
entity.Property(e => e.Language).HasMaxLength(8);
|
||||
});
|
||||
|
||||
// Configuratie voor SiteSettings (een rij, Id = 1)
|
||||
|
||||
@@ -28,6 +28,7 @@ public static class EmailServiceCollectionExtensions
|
||||
services.TryAddSingleton<IMailTemplateRenderer, MailTemplateRenderer>();
|
||||
services.TryAddSingleton<ILanguageResolver, LanguageResolver>();
|
||||
services.TryAddScoped<ISiteSettingsService, SiteSettingsService>();
|
||||
services.TryAddScoped<IIdentityMailService, IdentityMailService>();
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SlpModularCms.Core.Identity.Entities;
|
||||
using SlpModularCms.Core.Identity.Models;
|
||||
using SlpModularCms.Core.SiteSettings;
|
||||
|
||||
namespace SlpModularCms.Core.Email;
|
||||
|
||||
/// <summary>
|
||||
/// Builds and sends the identity mails (invitation, new link, notices). One orchestration point so a
|
||||
/// controller never knows about templates, languages, links or the sender.
|
||||
/// </summary>
|
||||
public interface IIdentityMailService
|
||||
{
|
||||
/// <summary>True when this site can send mail (an SMTP host is configured).</summary>
|
||||
bool IsEnabled { get; }
|
||||
|
||||
Task<MailSendResult> SendInvitationAsync(string email, string token, string? language, bool isNewLink, CancellationToken ct = default);
|
||||
Task<MailSendResult> SendAccountDeactivatedAsync(ApplicationUser user, CancellationToken ct = default);
|
||||
Task<MailSendResult> SendAccountReactivatedAsync(ApplicationUser user, CancellationToken ct = default);
|
||||
Task<MailSendResult> SendRoleChangedAsync(ApplicationUser user, string newRole, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
public sealed class IdentityMailService(
|
||||
IEmailSender sender,
|
||||
IMailTemplateRenderer renderer,
|
||||
ILanguageResolver languages,
|
||||
ISiteSettingsService siteSettings,
|
||||
IOptions<EmailOptions> email,
|
||||
IOptions<AppMailOptions> app,
|
||||
IOptions<InvitationSettings> invitation,
|
||||
ILogger<IdentityMailService> logger) : IIdentityMailService
|
||||
{
|
||||
public bool IsEnabled => !string.IsNullOrWhiteSpace(email.Value.Smtp.Host);
|
||||
|
||||
public Task<MailSendResult> SendInvitationAsync(string email, string token, string? language, bool isNewLink, CancellationToken ct = default) =>
|
||||
SendAsync(
|
||||
isNewLink ? MailKind.NewInvitationLink : MailKind.Invitation,
|
||||
email,
|
||||
language,
|
||||
recipientName: null,
|
||||
actionPath: "/invite/complete?token=" + Uri.EscapeDataString(token),
|
||||
validForMinutes: invitation.Value.ExpiryHours * 60,
|
||||
detail: null,
|
||||
ct);
|
||||
|
||||
public Task<MailSendResult> SendAccountDeactivatedAsync(ApplicationUser user, CancellationToken ct = default) =>
|
||||
SendAsync(MailKind.AccountDeactivated, user.Email, user.PreferredLanguage, user.DisplayName, null, null, null, ct);
|
||||
|
||||
public Task<MailSendResult> SendAccountReactivatedAsync(ApplicationUser user, CancellationToken ct = default) =>
|
||||
SendAsync(MailKind.AccountReactivated, user.Email, user.PreferredLanguage, user.DisplayName, "/login", null, null, ct);
|
||||
|
||||
public Task<MailSendResult> SendRoleChangedAsync(ApplicationUser user, string newRole, CancellationToken ct = default) =>
|
||||
SendAsync(MailKind.RoleChanged, user.Email, user.PreferredLanguage, user.DisplayName, null, null, newRole, ct);
|
||||
|
||||
private async Task<MailSendResult> SendAsync(
|
||||
MailKind kind, string? to, string? language, string? recipientName, string? actionPath,
|
||||
int? validForMinutes, string? detail, CancellationToken ct)
|
||||
{
|
||||
if (!IsEnabled) return MailSendResult.Fail(MailSendResult.Disabled);
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(to)) return MailSendResult.Fail(MailSendResult.Rejected);
|
||||
|
||||
var (fromAddress, fromName) = await siteSettings.GetEffectiveSenderAsync(ct);
|
||||
var baseUrl = app.Value.PublicBaseUrl.TrimEnd('/');
|
||||
var model = new MailModel(
|
||||
SiteName: fromName,
|
||||
RecipientName: recipientName,
|
||||
ActionUrl: actionPath is null ? null : BuildLink(baseUrl, actionPath),
|
||||
ValidForMinutes: validForMinutes,
|
||||
Detail: detail,
|
||||
LogoUrl: ResolveLogo(baseUrl, email.Value.LogoUrl),
|
||||
BrandColor: string.IsNullOrWhiteSpace(email.Value.BrandColor) ? null : email.Value.BrandColor);
|
||||
|
||||
var rendered = renderer.Render(kind, languages.Resolve(language), model);
|
||||
var result = await sender.SendAsync(
|
||||
new OutgoingMail(to, rendered.Subject, rendered.Html, rendered.Text, fromAddress, fromName), ct);
|
||||
|
||||
// Recipient DOMAIN only: never the address, the link or the token.
|
||||
var domain = to.Contains('@') ? to[(to.LastIndexOf('@') + 1)..] : "?";
|
||||
if (result.Sent)
|
||||
logger.LogInformation("identity_mail_sent kind={Kind} recipient_domain={Domain}", kind, domain);
|
||||
else
|
||||
logger.LogWarning("identity_mail_failed kind={Kind} recipient_domain={Domain} code={Code}", kind, domain, result.ErrorCode);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning("identity_mail_failed kind={Kind} code={Code} exception={ExceptionType}", kind, MailSendResult.Unknown, ex.GetType().Name);
|
||||
return MailSendResult.Fail(MailSendResult.Unknown);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Public site address + the admin base path + the app path (the admin is mounted under /admin).</summary>
|
||||
public static string BuildLink(string publicBaseUrl, string appPath) =>
|
||||
publicBaseUrl.TrimEnd('/') + "/admin" + (appPath.StartsWith('/') ? appPath : "/" + appPath);
|
||||
|
||||
private static string? ResolveLogo(string baseUrl, string? logoUrl)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(logoUrl)) return null;
|
||||
return logoUrl.StartsWith('/') ? baseUrl + logoUrl : logoUrl;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,9 @@ namespace SlpModularCms.Core.Identity.Authorization;
|
||||
/// </remarks>
|
||||
public static class ActiveUserTokenValidation
|
||||
{
|
||||
/// <summary>Claim carrying the user's security stamp at the moment the access token was issued.</summary>
|
||||
public const string StampClaim = "stamp";
|
||||
|
||||
/// <summary>
|
||||
/// The one place the bearer scheme is configured: signature/lifetime parameters plus the
|
||||
/// active-account check. Hosts and tests both go through this, so the check cannot be dropped
|
||||
@@ -46,16 +49,26 @@ public static class ActiveUserTokenValidation
|
||||
}
|
||||
|
||||
var db = context.HttpContext.RequestServices.GetRequiredService<ApplicationDbContext>();
|
||||
var isActive = await db.Users
|
||||
var user = await db.Users
|
||||
.AsNoTracking()
|
||||
.Where(u => u.Id == userId)
|
||||
.Select(u => (bool?)u.IsActive)
|
||||
.Select(u => new { u.IsActive, u.SecurityStamp })
|
||||
.FirstOrDefaultAsync(context.HttpContext.RequestAborted);
|
||||
|
||||
if (isActive != true)
|
||||
if (user is null || !user.IsActive)
|
||||
{
|
||||
// Same 401 whether the user is gone or deactivated: which one is not the caller's business.
|
||||
context.Fail("Account is not active.");
|
||||
return;
|
||||
}
|
||||
|
||||
// A password change or reset changes the stamp, which ends every access token issued before it.
|
||||
// A token without the claim (issued before this check existed) is refused once; the refresh
|
||||
// token then silently issues a new one that carries it.
|
||||
var tokenStamp = principal?.FindFirstValue(StampClaim);
|
||||
if (tokenStamp is null || !string.Equals(tokenStamp, user.SecurityStamp ?? string.Empty, StringComparison.Ordinal))
|
||||
{
|
||||
context.Fail("Session is no longer valid.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,11 @@ public class ApplicationUser : IdentityUser<Guid>
|
||||
/// </summary>
|
||||
public string? DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Voorkeurstaal van de gebruiker (nl of en), ook voor e-mails. Null = standaardtaal van de site.
|
||||
/// </summary>
|
||||
public string? PreferredLanguage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Navigatie-eigenschap naar module-specifieke rechten.
|
||||
/// </summary>
|
||||
|
||||
@@ -12,6 +12,10 @@ public class Invitation
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Role { get; set; } = string.Empty;
|
||||
public string Token { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Taal van de uitnodigingsmail en voorkeurstaal van het nieuwe account (nl of en); null = sitestandaard.</summary>
|
||||
public string? Language { get; set; }
|
||||
|
||||
public DateTimeOffset ExpiryDate { get; set; }
|
||||
public bool IsAccepted { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
|
||||
@@ -4,13 +4,13 @@ namespace SlpModularCms.Core.Identity.Models;
|
||||
|
||||
[ExcludeFromCodeCoverage] public record CreateOwnerRequest(string Name, string Email, string Password);
|
||||
[ExcludeFromCodeCoverage] public record LoginRequest(string Email, string Password);
|
||||
[ExcludeFromCodeCoverage] public record InviteUserRequest(string Email, string Role);
|
||||
[ExcludeFromCodeCoverage] public record InviteUserRequest(string Email, string Role, string? Language = null);
|
||||
[ExcludeFromCodeCoverage] public record CompleteSetupRequest(string Token, string Password, string? Name = null);
|
||||
[ExcludeFromCodeCoverage] public record ChangeRoleRequest(string NewRole);
|
||||
[ExcludeFromCodeCoverage] public record UpdateProfileRequest(string Name, string Email);
|
||||
[ExcludeFromCodeCoverage] public record UpdateProfileRequest(string Name, string Email, string? Language = null);
|
||||
[ExcludeFromCodeCoverage] public record ChangePasswordRequest(string CurrentPassword, string NewPassword);
|
||||
[ExcludeFromCodeCoverage] public record SetUserActiveRequest(bool IsActive);
|
||||
[ExcludeFromCodeCoverage] public record PendingInvitationInfo(Guid Id, string Email, string Role, string Token, DateTimeOffset CreatedAt, bool IsExpired = false);
|
||||
[ExcludeFromCodeCoverage] public record PendingInvitationInfo(Guid Id, string Email, string Role, string Token, DateTimeOffset CreatedAt, bool IsExpired = false, string? Language = null);
|
||||
[ExcludeFromCodeCoverage]
|
||||
public record UserDto(
|
||||
Guid Id,
|
||||
@@ -21,4 +21,5 @@ public record UserDto(
|
||||
DateTimeOffset CreatedAt,
|
||||
bool InvitationPending,
|
||||
string? InviteLink,
|
||||
bool InvitationExpired = false);
|
||||
bool InvitationExpired = false,
|
||||
string? Language = null);
|
||||
|
||||
@@ -23,5 +23,6 @@ public record UserResponse(
|
||||
string Email,
|
||||
string Name,
|
||||
string Role,
|
||||
bool IsActive
|
||||
bool IsActive,
|
||||
string? Language = null
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using SlpModularCms.Core.Data;
|
||||
using SlpModularCms.Core.Exceptions;
|
||||
using SlpModularCms.Core.Identity.Authorization;
|
||||
using SlpModularCms.Core.Identity.Entities;
|
||||
using SlpModularCms.Core.Identity.Models;
|
||||
using SlpModularCms.Core.Observability;
|
||||
@@ -117,7 +118,10 @@ public class AuthService : IAuthService
|
||||
{
|
||||
new(JwtRegisteredClaimNames.Sub, user.Id.ToString()),
|
||||
new(JwtRegisteredClaimNames.Email, user.Email!),
|
||||
new(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
|
||||
new(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
|
||||
// The security stamp changes on a password change/reset. The access-token check compares it, so
|
||||
// such a change ends every access token issued before it (see ActiveUserTokenValidation).
|
||||
new(ActiveUserTokenValidation.StampClaim, user.SecurityStamp ?? string.Empty)
|
||||
};
|
||||
|
||||
foreach (var role in roles)
|
||||
@@ -155,7 +159,8 @@ public class AuthService : IAuthService
|
||||
Email: user.Email!,
|
||||
Name: user.DisplayName ?? user.Email!,
|
||||
Role: primaryRole,
|
||||
IsActive: user.IsActive
|
||||
IsActive: user.IsActive,
|
||||
Language: user.PreferredLanguage
|
||||
);
|
||||
|
||||
return new TokenResponse(accessToken, refreshToken, expiry, userResponse);
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface IInvitationService
|
||||
/// <summary>
|
||||
/// Maakt een nieuwe uitnodiging aan en retourneert het token.
|
||||
/// </summary>
|
||||
Task<string> CreateInvitationAsync(string email, string role);
|
||||
Task<string> CreateInvitationAsync(string email, string role, string? language = null);
|
||||
|
||||
/// <summary>
|
||||
/// Valideert of een uitnodigings-token nog geldig is.
|
||||
|
||||
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SlpModularCms.Core.Data;
|
||||
using SlpModularCms.Core.Email;
|
||||
using SlpModularCms.Core.Exceptions;
|
||||
using SlpModularCms.Core.Identity.Entities;
|
||||
using SlpModularCms.Core.Identity.Models;
|
||||
@@ -25,7 +26,7 @@ public class InvitationService : IInvitationService
|
||||
_settings = settings.Value;
|
||||
}
|
||||
|
||||
public async Task<string> CreateInvitationAsync(string email, string role)
|
||||
public async Task<string> CreateInvitationAsync(string email, string role, string? language = null)
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(email);
|
||||
if (user != null)
|
||||
@@ -57,6 +58,7 @@ public class InvitationService : IInvitationService
|
||||
{
|
||||
Email = email,
|
||||
Role = role,
|
||||
Language = MailLanguages.Normalize(language),
|
||||
Token = token,
|
||||
ExpiryDate = DateTimeOffset.UtcNow.AddHours(_settings.ExpiryHours),
|
||||
IsAccepted = false
|
||||
@@ -87,6 +89,7 @@ public class InvitationService : IInvitationService
|
||||
UserName = invitation.Email,
|
||||
Email = invitation.Email,
|
||||
DisplayName = string.IsNullOrWhiteSpace(name) ? null : name.Trim(),
|
||||
PreferredLanguage = invitation.Language,
|
||||
IsActive = true
|
||||
};
|
||||
|
||||
@@ -131,7 +134,7 @@ public class InvitationService : IInvitationService
|
||||
// Expired ones are included on purpose: dropping them made an invited person who did not
|
||||
// activate in time vanish from the list, so the administrator could neither see nor remove them.
|
||||
return invitations
|
||||
.Select(i => new PendingInvitationInfo(i.Id, i.Email, i.Role, i.Token, i.CreatedAt, i.IsExpired))
|
||||
.Select(i => new PendingInvitationInfo(i.Id, i.Email, i.Role, i.Token, i.CreatedAt, i.IsExpired, i.Language))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
+474
@@ -0,0 +1,474 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using SlpModularCms.Core.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SlpModularCms.Core.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20261108180809_AddLanguagePreference")]
|
||||
partial class AddLanguagePreference
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.9")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FriendlyName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Xml")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("DataProtectionKeys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("RoleId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("RoleClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("UserClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("UserLogins", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("RoleId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("UserRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("UserTokens", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SlpModularCms.Core.Identity.Entities.ApplicationRole", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("RoleNameIndex");
|
||||
|
||||
b.ToTable("Roles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SlpModularCms.Core.Identity.Entities.ApplicationUser", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("AccessFailedCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
b.Property<string>("DisplayName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("LockoutEnabled")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("PreferredLanguage")
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("varchar(8)");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
b.ToTable("Users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SlpModularCms.Core.Identity.Entities.GlobalAvailabilityState", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTimeOffset>("LastUpdatedAt")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("UpdatedBy")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("AvailabilityState", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SlpModularCms.Core.Identity.Entities.Invitation", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<DateTimeOffset>("ExpiryDate")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
b.Property<bool>("IsAccepted")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Language")
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("varchar(8)");
|
||||
|
||||
b.Property<string>("Role")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Token")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Token")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Invitations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SlpModularCms.Core.Identity.Entities.ModulePermission", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("ModuleName")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.Property<string>("Permission")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)");
|
||||
|
||||
b.HasKey("UserId", "ModuleName", "Permission");
|
||||
|
||||
b.ToTable("ModulePermissions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SlpModularCms.Core.Identity.Entities.RefreshToken", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
b.Property<string>("CreatedByIp")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTimeOffset>("ExpiryDate")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
b.Property<bool>("IsRevoked")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("IsUsed")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Token")
|
||||
.IsRequired()
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Token")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("RefreshTokens");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SlpModularCms.Core.SiteSettings.SiteSettingsEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("MailFromAddress")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.Property<string>("MailFromName")
|
||||
.HasMaxLength(80)
|
||||
.HasColumnType("varchar(80)");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.HasColumnType("datetime");
|
||||
|
||||
b.Property<string>("UpdatedBy")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("varchar(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SiteSettings", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
|
||||
{
|
||||
b.HasOne("SlpModularCms.Core.Identity.Entities.ApplicationRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
|
||||
{
|
||||
b.HasOne("SlpModularCms.Core.Identity.Entities.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
|
||||
{
|
||||
b.HasOne("SlpModularCms.Core.Identity.Entities.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
|
||||
{
|
||||
b.HasOne("SlpModularCms.Core.Identity.Entities.ApplicationRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("SlpModularCms.Core.Identity.Entities.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
|
||||
{
|
||||
b.HasOne("SlpModularCms.Core.Identity.Entities.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SlpModularCms.Core.Identity.Entities.ModulePermission", b =>
|
||||
{
|
||||
b.HasOne("SlpModularCms.Core.Identity.Entities.ApplicationUser", "User")
|
||||
.WithMany("ModulePermissions")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SlpModularCms.Core.Identity.Entities.RefreshToken", b =>
|
||||
{
|
||||
b.HasOne("SlpModularCms.Core.Identity.Entities.ApplicationUser", "User")
|
||||
.WithMany("RefreshTokens")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SlpModularCms.Core.Identity.Entities.ApplicationUser", b =>
|
||||
{
|
||||
b.Navigation("ModulePermissions");
|
||||
|
||||
b.Navigation("RefreshTokens");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SlpModularCms.Core.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddLanguagePreference : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PreferredLanguage",
|
||||
table: "Users",
|
||||
type: "varchar(8)",
|
||||
maxLength: 8,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Language",
|
||||
table: "Invitations",
|
||||
type: "varchar(8)",
|
||||
maxLength: 8,
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PreferredLanguage",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Language",
|
||||
table: "Invitations");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,6 +214,10 @@ namespace SlpModularCms.Core.Migrations
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("PreferredLanguage")
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("varchar(8)");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@@ -279,6 +283,10 @@ namespace SlpModularCms.Core.Migrations
|
||||
b.Property<bool>("IsAccepted")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Language")
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("varchar(8)");
|
||||
|
||||
b.Property<string>("Role")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
Reference in New Issue
Block a user