AppUser new structure

master
Tudor Stanciu 2021-11-11 01:20:02 +02:00
parent 4f0db24b5b
commit 4f30ab0c98
7 changed files with 50 additions and 4 deletions

View File

@ -1,7 +1,7 @@
{ {
"urls": "http://*:5063", "urls": "http://*:5063",
"ConnectionStrings": { "ConnectionStrings": {
"DatabaseConnection": "Server=***REMOVED***;Database=IdentityServer_dev;User Id=sa;Password=***REMOVED***;MultipleActiveResultSets=true" "DatabaseConnection": "***REMOVED***"
}, },
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {

View File

@ -10,6 +10,7 @@ namespace IdentityServer.Domain.Data.EntityTypeConfiguration
{ {
builder.ToTable("AppUser").HasKey(key => key.UserId); builder.ToTable("AppUser").HasKey(key => key.UserId);
builder.Property(z => z.UserId).ValueGeneratedOnAdd(); builder.Property(z => z.UserId).ValueGeneratedOnAdd();
builder.HasOne(z => z.Status).WithMany().HasForeignKey(z => z.StatusId);
} }
} }
} }

View File

@ -0,0 +1,15 @@
using IdentityServer.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace IdentityServer.Domain.Data.EntityTypeConfiguration
{
class UserStatusConfiguration : IEntityTypeConfiguration<UserStatus>
{
public void Configure(EntityTypeBuilder<UserStatus> builder)
{
builder.ToTable("UserStatus").HasKey(z => z.StatusId);
builder.Property(z => z.StatusId).ValueGeneratedOnAdd();
}
}
}

View File

@ -2,7 +2,7 @@ if not exists (select top 1 1 from sys.objects where name = 'UserStatus' and typ
begin begin
create table UserStatus create table UserStatus
( (
StatusId int identity(0, 1) constraint PK_UserStatus primary key, StatusId int identity(1, 1) constraint PK_UserStatus primary key,
StatusCode varchar(30) not null, StatusCode varchar(30) not null,
StatusName varchar(50) not null StatusName varchar(50) not null
) )

View File

@ -1,3 +1,10 @@
if exists (select top 1 1 from sys.objects where name = 'AppUser' and type = 'U')
and not exists(select top 1 1 from sys.columns where name = 'SecurityStamp' and object_id = object_id('AppUser'))
begin
select * into #TmpAppUser from AppUser
drop table AppUser
end
if not exists (select top 1 1 from sys.objects where name = 'AppUser' and type = 'U') if not exists (select top 1 1 from sys.objects where name = 'AppUser' and type = 'U')
begin begin
create table AppUser create table AppUser
@ -21,7 +28,13 @@ go
if not exists (select top 1 1 from AppUser) if not exists (select top 1 1 from AppUser)
begin begin
insert into AppUser(UserName, [Password]) declare @activeStatusId int
select '***REMOVED***', '***REMOVED***' select @activeStatusId = StatusId from UserStatus where StatusCode = 'ACTIVE'
insert into AppUser(UserName, [Password], CreationDate, SecurityStamp, StatusId)
select UserName, [Password], CreationDate, cast(newid() as varchar(100)), @activeStatusId as StatusId
from #TmpAppUser
drop table #TmpAppUser
end end
go go

View File

@ -7,8 +7,16 @@ namespace IdentityServer.Domain.Entities
public int UserId { get; set; } public int UserId { get; set; }
public string UserName { get; set; } public string UserName { get; set; }
public string Password { get; set; } public string Password { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; } public string Email { get; set; }
public string ProfilePictureUrl { get; set; } public string ProfilePictureUrl { get; set; }
public string SecurityStamp { get; set; }
public int StatusId { get; set; }
public DateTime CreationDate { get; set; } public DateTime CreationDate { get; set; }
public int FailedLoginAttempts { get; set; }
public DateTime LastLoginDate { get; set; }
public DateTime PasswordChangeDate { get; set; }
public UserStatus Status { get; set; }
} }
} }

View File

@ -0,0 +1,9 @@
namespace IdentityServer.Domain.Entities
{
public class UserStatus
{
public int StatusId { get; set; }
public string StatusCode { get; set; }
public string StatusName { get; set; }
}
}