diff --git a/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs index a1fda6455..61c674a12 100644 --- a/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs @@ -74,7 +74,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data "cardholdername", "cardnumber", "cardtype", "city", "country", "email", "expiration", "lastname", "name", "phonenumber", "username", "zipcode", "state", "street", "securitynumber", - "normalizedemail", "normalizedusername", "password" + "normalizedemail", "normalizedusername", "password", "tenantid" }; csvheaders = GetHeaders(requiredHeaders, csvFileUsers); } @@ -104,10 +104,16 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data } string cardtypeString = column[Array.IndexOf(headers, "cardtype")].Trim('"').Trim(); + string tenantIdString = column[Array.IndexOf(headers, "tenantid")].Trim('"').Trim(); if (!int.TryParse(cardtypeString, out int cardtype)) { throw new Exception($"cardtype='{cardtypeString}' is not a number"); } + + if (!int.TryParse(tenantIdString, out int tenantId)) + { + throw new Exception($"tenantid='{tenantIdString}' is not a number"); + } var user = new ApplicationUser { @@ -131,6 +137,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data NormalizedUserName = column[Array.IndexOf(headers, "normalizedusername")].Trim('"').Trim(), SecurityStamp = Guid.NewGuid().ToString("D"), PasswordHash = column[Array.IndexOf(headers, "password")].Trim('"').Trim(), // Note: This is the password + TenantId = tenantId }; user.PasswordHash = _passwordHasher.HashPassword(user, user.PasswordHash); @@ -162,13 +169,41 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data NormalizedEmail = "DEMOUSER@MICROSOFT.COM", NormalizedUserName = "DEMOUSER@MICROSOFT.COM", SecurityStamp = Guid.NewGuid().ToString("D"), + TenantId = 2 }; + + var user2 = + new ApplicationUser() + { + CardHolderName = "Espen", + CardNumber = "4012888888881882", + CardType = 1, + City = "Oslo", + Country = "Norway", + Email = "espent1004@gmail.com", + Expiration = "12/22", + Id = Guid.NewGuid().ToString(), + LastName = "Nordli", + Name = "Espen", + PhoneNumber = "95791135", + UserName = "espent1004@gmail.com", + ZipCode = "0681", + State = "Oslo", + Street = "Treskeveien 28A", + SecurityNumber = "535", + NormalizedEmail = "ESPENT1004@GMAIL.COM", + NormalizedUserName = "ESPENT1004@GMAIL.COM", + SecurityStamp = Guid.NewGuid().ToString("D"), + TenantId = 1 + }; user.PasswordHash = _passwordHasher.HashPassword(user, "Pass@word1"); + user2.PasswordHash = _passwordHasher.HashPassword(user2, "passord"); return new List() { - user + user, + user2 }; } diff --git a/src/Services/Identity/Identity.API/Migrations/20170912114036_Initial.Designer.cs b/src/Services/Identity/Identity.API/Migrations/20170912114036_Initial.Designer.cs index 0850b37b9..fdb53ac4b 100644 --- a/src/Services/Identity/Identity.API/Migrations/20170912114036_Initial.Designer.cs +++ b/src/Services/Identity/Identity.API/Migrations/20170912114036_Initial.Designer.cs @@ -29,6 +29,9 @@ namespace Identity.API.Migrations b.Property("CardHolderName") .IsRequired(); + b.Property("TenantId") + .IsRequired(); + b.Property("CardNumber") .IsRequired(); diff --git a/src/Services/Identity/Identity.API/Migrations/20170912114036_Initial.cs b/src/Services/Identity/Identity.API/Migrations/20170912114036_Initial.cs index cf771dac8..fba2f8dcf 100644 --- a/src/Services/Identity/Identity.API/Migrations/20170912114036_Initial.cs +++ b/src/Services/Identity/Identity.API/Migrations/20170912114036_Initial.cs @@ -53,7 +53,8 @@ namespace Identity.API.Migrations Street = table.Column(type: "nvarchar(max)", nullable: false), TwoFactorEnabled = table.Column(type: "bit", nullable: false), UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - ZipCode = table.Column(type: "nvarchar(max)", nullable: false) + ZipCode = table.Column(type: "nvarchar(max)", nullable: false), + TenantId = table.Column(type: "int", nullable: false), }, constraints: table => { diff --git a/src/Services/Identity/Identity.API/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Services/Identity/Identity.API/Migrations/ApplicationDbContextModelSnapshot.cs index dcc87bc73..cbcb28771 100644 --- a/src/Services/Identity/Identity.API/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Services/Identity/Identity.API/Migrations/ApplicationDbContextModelSnapshot.cs @@ -24,6 +24,9 @@ namespace Identity.API.Migrations b.Property("AccessFailedCount"); + b.Property("TenantId") + .IsRequired(); + b.Property("CardHolderName") .IsRequired(); diff --git a/src/Services/Identity/Identity.API/Models/ApplicationUser.cs b/src/Services/Identity/Identity.API/Models/ApplicationUser.cs index fa43017fc..e18060935 100644 --- a/src/Services/Identity/Identity.API/Models/ApplicationUser.cs +++ b/src/Services/Identity/Identity.API/Models/ApplicationUser.cs @@ -30,5 +30,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models public string Name { get; set; } [Required] public string LastName { get; set; } + [Required] + public int TenantId { get; set; } } } diff --git a/src/Services/Identity/Identity.API/Setup/Users.csv b/src/Services/Identity/Identity.API/Setup/Users.csv index 3e5081078..e941adba7 100644 --- a/src/Services/Identity/Identity.API/Setup/Users.csv +++ b/src/Services/Identity/Identity.API/Setup/Users.csv @@ -1,2 +1,3 @@ -CardHolderName,CardNumber,CardType,City,Country,Email,Expiration,LastName,Name,PhoneNumber,UserName,ZipCode,State,Street,SecurityNumber,NormalizedEmail,NormalizedUserName,Password -DemoUser,4012888888881881,1,Redmond,U.S.,demouser@microsoft.com,12/20,DemoLastName,DemoUser,1234567890,demouser@microsoft.com,98052,WA,15703 NE 61st Ct,535,DEMOUSER@MICROSOFT.COM,DEMOUSER@MICROSOFT.COM,Pass@word1 \ No newline at end of file +CardHolderName,CardNumber,CardType,City,Country,Email,Expiration,LastName,Name,PhoneNumber,UserName,ZipCode,State,Street,SecurityNumber,NormalizedEmail,NormalizedUserName,Password,TenantId +DemoUser,4012888888881881,1,Redmond,U.S.,demouser@microsoft.com,12/20,DemoLastName,DemoUser,1234567890,demouser@microsoft.com,98052,WA,15703 NE 61st Ct,535,DEMOUSER@MICROSOFT.COM,DEMOUSER@MICROSOFT.COM,Pass@word1,1 +Espen Nordli,4012888888881882,1,Oslo,Norway,espent1004@gmail.com,12/20,Nordli,Espen,95791135,espent1004@gmail.com,0681,Oslo,Treskeveien 28A,535,ESPENT1004@GMAIL.COM,ESPENT1004@GMAIL.COM,Pass@word1,2 \ No newline at end of file