diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/Connected Services/AuthenticationsGeneratedServices/OpenAPI.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/Connected Services/AuthenticationsGeneratedServices/OpenAPI.cs index 228ee95..dfe5f46 100644 --- a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/Connected Services/AuthenticationsGeneratedServices/OpenAPI.cs +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/Connected Services/AuthenticationsGeneratedServices/OpenAPI.cs @@ -53,6 +53,84 @@ public string BaseUrl partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); + /// Success + /// A server side error occurred. + public virtual System.Threading.Tasks.Task VerifyUserNameAsync(VerifyEmailAddressContract body) + { + return VerifyUserNameAsync(body, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// Success + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task VerifyUserNameAsync(VerifyEmailAddressContract body, System.Threading.CancellationToken cancellationToken) + { + var urlBuilder_ = new System.Text.StringBuilder(); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/Users/VerifyUserName"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value); + var content_ = new System.Net.Http.StringContent(json_); + content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + request_.Content = content_; + request_.Method = new System.Net.Http.HttpMethod("POST"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + /// Success /// A server side error occurred. public virtual System.Threading.Tasks.Task RegisterAsync(AddUserRequestContract body) @@ -1208,6 +1286,68 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } } + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.3.0))")] + public partial class BooleanMessageContract : System.ComponentModel.INotifyPropertyChanged + { + private bool _isSuccess; + private ErrorContract _error; + private bool _result; + + [Newtonsoft.Json.JsonProperty("isSuccess", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public bool IsSuccess + { + get { return _isSuccess; } + + set + { + if (_isSuccess != value) + { + _isSuccess = value; + RaisePropertyChanged(); + } + } + } + + [Newtonsoft.Json.JsonProperty("error", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public ErrorContract Error + { + get { return _error; } + + set + { + if (_error != value) + { + _error = value; + RaisePropertyChanged(); + } + } + } + + [Newtonsoft.Json.JsonProperty("result", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public bool Result + { + get { return _result; } + + set + { + if (_result != value) + { + _result = value; + RaisePropertyChanged(); + } + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.3.0))")] public partial class ClaimContract : System.ComponentModel.INotifyPropertyChanged { @@ -1767,6 +1907,7 @@ public partial class UserContract : System.ComponentModel.INotifyPropertyChanged private System.DateTimeOffset? _modificationDateTime; private bool _isDeleted; private System.DateTimeOffset? _deletedDateTime; + private bool _isUsernameVerified; [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public long Id @@ -1888,6 +2029,21 @@ public System.DateTimeOffset? DeletedDateTime } } + [Newtonsoft.Json.JsonProperty("isUsernameVerified", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public bool IsUsernameVerified + { + get { return _isUsernameVerified; } + + set + { + if (_isUsernameVerified != value) + { + _isUsernameVerified = value; + RaisePropertyChanged(); + } + } + } + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) @@ -2206,6 +2362,36 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal } } + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.3.0))")] + public partial class VerifyEmailAddressContract : System.ComponentModel.INotifyPropertyChanged + { + private long _userId; + + [Newtonsoft.Json.JsonProperty("userId", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public long UserId + { + get { return _userId; } + + set + { + if (_userId != value) + { + _userId = value; + RaisePropertyChanged(); + } + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.3.0))")] diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/Connected Services/AuthenticationsGeneratedServices/OpenAPI.nswag.json b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/Connected Services/AuthenticationsGeneratedServices/OpenAPI.nswag.json index 52f1fe3..92cf71d 100644 --- a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/Connected Services/AuthenticationsGeneratedServices/OpenAPI.nswag.json +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/Connected Services/AuthenticationsGeneratedServices/OpenAPI.nswag.json @@ -5,6 +5,55 @@ "version": "1.0" }, "paths": { + "/api/Users/VerifyUserName": { + "post": { + "tags": [ + "Users" + ], + "operationId": "VerifyUserName", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VerifyEmailAddressContract" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/VerifyEmailAddressContract" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/VerifyEmailAddressContract" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/BooleanMessageContract" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/BooleanMessageContract" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/BooleanMessageContract" + } + } + } + } + } + } + }, "/api/Users/Register": { "post": { "tags": [ @@ -621,6 +670,22 @@ } } }, + "BooleanMessageContract": { + "title": "MessageContract", + "type": "object", + "additionalProperties": false, + "properties": { + "isSuccess": { + "type": "boolean" + }, + "error": { + "$ref": "#/components/schemas/ErrorContract" + }, + "result": { + "type": "boolean" + } + } + }, "ClaimContract": { "type": "object", "additionalProperties": false, @@ -863,6 +928,9 @@ "type": "string", "format": "date-time", "nullable": true + }, + "isUsernameVerified": { + "type": "boolean" } } }, @@ -956,6 +1024,16 @@ "nullable": true } } + }, + "VerifyEmailAddressContract": { + "type": "object", + "additionalProperties": false, + "properties": { + "userId": { + "type": "integer", + "format": "int64" + } + } } }, "securitySchemes": { diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/EasyMicroservices.AuthenticationsMicroservice.Clients.csproj b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/EasyMicroservices.AuthenticationsMicroservice.Clients.csproj index 54dc15a..277704e 100644 --- a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/EasyMicroservices.AuthenticationsMicroservice.Clients.csproj +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Clients/EasyMicroservices.AuthenticationsMicroservice.Clients.csproj @@ -5,7 +5,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.6 + 0.0.0.7 client generated code. EasyMicroservices@gmail.com microservice,auth,authentication,client diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Database/Schemas/UserSchema.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Database/Schemas/UserSchema.cs index 74ee7c4..2a0ada7 100644 --- a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Database/Schemas/UserSchema.cs +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Database/Schemas/UserSchema.cs @@ -19,5 +19,6 @@ public class UserSchema : IUniqueIdentitySchema, ISoftDeleteSchema, IDateTimeSch public DateTime? ModificationDateTime { get; set; } public bool IsDeleted { get; set; } public DateTime? DeletedDateTime { get; set; } + public bool IsUsernameVerified { get; set; } } } diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20230930162403_update.Designer.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20230930162403_update.Designer.cs new file mode 100644 index 0000000..5e41a44 --- /dev/null +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20230930162403_update.Designer.cs @@ -0,0 +1,79 @@ +// +using System; +using EasyMicroservices.AuthenticationsMicroservice.Database.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EasyMicroservices.AuthenticationsMicroservice.Migrations +{ + [DbContext(typeof(AuthenticationsContext))] + [Migration("20230930162403_update")] + partial class update + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EasyMicroservices.AuthenticationsMicroservice.Database.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreationDateTime") + .HasColumnType("datetime2"); + + b.Property("DeletedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModificationDateTime") + .HasColumnType("datetime2"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("UniqueIdentity") + .HasColumnType("nvarchar(450)") + .UseCollation("SQL_Latin1_General_CP1_CS_AS"); + + b.Property("UserName") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("CreationDateTime"); + + b.HasIndex("DeletedDateTime"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ModificationDateTime"); + + b.HasIndex("UniqueIdentity"); + + b.HasIndex("UserName") + .IsUnique() + .HasFilter("[UserName] IS NOT NULL"); + + b.ToTable("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20230930162403_update.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20230930162403_update.cs new file mode 100644 index 0000000..dc4603d --- /dev/null +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20230930162403_update.cs @@ -0,0 +1,73 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EasyMicroservices.AuthenticationsMicroservice.Migrations +{ + /// + public partial class update : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserName = table.Column(type: "nvarchar(450)", nullable: true), + Password = table.Column(type: "nvarchar(max)", nullable: true), + UniqueIdentity = table.Column(type: "nvarchar(450)", nullable: true, collation: "SQL_Latin1_General_CP1_CS_AS"), + CreationDateTime = table.Column(type: "datetime2", nullable: false), + ModificationDateTime = table.Column(type: "datetime2", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), + DeletedDateTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Users_CreationDateTime", + table: "Users", + column: "CreationDateTime"); + + migrationBuilder.CreateIndex( + name: "IX_Users_DeletedDateTime", + table: "Users", + column: "DeletedDateTime"); + + migrationBuilder.CreateIndex( + name: "IX_Users_IsDeleted", + table: "Users", + column: "IsDeleted"); + + migrationBuilder.CreateIndex( + name: "IX_Users_ModificationDateTime", + table: "Users", + column: "ModificationDateTime"); + + migrationBuilder.CreateIndex( + name: "IX_Users_UniqueIdentity", + table: "Users", + column: "UniqueIdentity"); + + migrationBuilder.CreateIndex( + name: "IX_Users_UserName", + table: "Users", + column: "UserName", + unique: true, + filter: "[UserName] IS NOT NULL"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20231007164110_Add_VerifyEmailAddress.Designer.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20231007164110_Add_VerifyEmailAddress.Designer.cs new file mode 100644 index 0000000..9d1a0a8 --- /dev/null +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20231007164110_Add_VerifyEmailAddress.Designer.cs @@ -0,0 +1,82 @@ +// +using System; +using EasyMicroservices.AuthenticationsMicroservice.Database.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EasyMicroservices.AuthenticationsMicroservice.Migrations +{ + [DbContext(typeof(AuthenticationsContext))] + [Migration("20231007164110_Add_VerifyEmailAddress")] + partial class Add_VerifyEmailAddress + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EasyMicroservices.AuthenticationsMicroservice.Database.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreationDateTime") + .HasColumnType("datetime2"); + + b.Property("DeletedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsernameVerified") + .HasColumnType("bit"); + + b.Property("ModificationDateTime") + .HasColumnType("datetime2"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("UniqueIdentity") + .HasColumnType("nvarchar(450)") + .UseCollation("SQL_Latin1_General_CP1_CS_AS"); + + b.Property("UserName") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("CreationDateTime"); + + b.HasIndex("DeletedDateTime"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ModificationDateTime"); + + b.HasIndex("UniqueIdentity"); + + b.HasIndex("UserName") + .IsUnique() + .HasFilter("[UserName] IS NOT NULL"); + + b.ToTable("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20231007164110_Add_VerifyEmailAddress.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20231007164110_Add_VerifyEmailAddress.cs new file mode 100644 index 0000000..d8a14c7 --- /dev/null +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/20231007164110_Add_VerifyEmailAddress.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EasyMicroservices.AuthenticationsMicroservice.Migrations +{ + /// + public partial class Add_VerifyEmailAddress : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsUsernameVerified", + table: "Users", + type: "bit", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsUsernameVerified", + table: "Users"); + } + } +} diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/AuthenticationsContextModelSnapshot.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/AuthenticationsContextModelSnapshot.cs new file mode 100644 index 0000000..bb3c822 --- /dev/null +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Database/Migrations/AuthenticationsContextModelSnapshot.cs @@ -0,0 +1,79 @@ +// +using System; +using EasyMicroservices.AuthenticationsMicroservice.Database.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EasyMicroservices.AuthenticationsMicroservice.Migrations +{ + [DbContext(typeof(AuthenticationsContext))] + partial class AuthenticationsContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EasyMicroservices.AuthenticationsMicroservice.Database.Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreationDateTime") + .HasColumnType("datetime2"); + + b.Property("DeletedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsUsernameVerified") + .HasColumnType("bit"); + + b.Property("ModificationDateTime") + .HasColumnType("datetime2"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("UniqueIdentity") + .HasColumnType("nvarchar(450)") + .UseCollation("SQL_Latin1_General_CP1_CS_AS"); + + b.Property("UserName") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("CreationDateTime"); + + b.HasIndex("DeletedDateTime"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ModificationDateTime"); + + b.HasIndex("UniqueIdentity"); + + b.HasIndex("UserName") + .IsUnique() + .HasFilter("[UserName] IS NOT NULL"); + + b.ToTable("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Domain/Contracts/Common/UserContract.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Domain/Contracts/Common/UserContract.cs index a2e10b0..0b4b206 100644 --- a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Domain/Contracts/Common/UserContract.cs +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Domain/Contracts/Common/UserContract.cs @@ -17,5 +17,6 @@ public class UserContract : IUniqueIdentitySchema, ISoftDeleteSchema, IDateTimeS public DateTime? ModificationDateTime { get; set; } public bool IsDeleted { get; set; } public DateTime? DeletedDateTime { get; set; } + public bool IsUsernameVerified { get; set; } } } diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Domain/Contracts/Requests/VerifyEmailAddressContract.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Domain/Contracts/Requests/VerifyEmailAddressContract.cs new file mode 100644 index 0000000..4a3a915 --- /dev/null +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.Domain/Contracts/Requests/VerifyEmailAddressContract.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EasyMicroservices.AuthenticationsMicroservice.Contracts.Requests +{ + public class VerifyEmailAddressContract + { + public long UserId { get; set; } + } +} diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.StartUp/DatabaseBuilder.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.StartUp/DatabaseBuilder.cs index b512682..78809d6 100644 --- a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.StartUp/DatabaseBuilder.cs +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.StartUp/DatabaseBuilder.cs @@ -17,8 +17,8 @@ public class DatabaseBuilder : IDatabaseBuilder public void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseInMemoryDatabase("AuthDb"); - //optionsBuilder.UseSqlServer(config.GetConnectionString("local")); + //optionsBuilder.UseInMemoryDatabase("AuthDb"); + optionsBuilder.UseSqlServer(config.GetConnectionString("local")); } } } diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/Controllers/UserController.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/Controllers/UserController.cs index 1d29333..5269e9d 100644 --- a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/Controllers/UserController.cs +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/Controllers/UserController.cs @@ -32,7 +32,30 @@ public UsersController(IContractLogic> VerifyUserName(VerifyEmailAddressContract request) + { + var user = await _contractLogic.GetById(new Cores.Contracts.Requests.GetIdRequestContract { Id = request.UserId }); + if (user.IsSuccess) + { + var updateUser = await _contractLogic.Update(new UserContract + { + CreationDateTime = user.Result.CreationDateTime, + DeletedDateTime = user.Result.DeletedDateTime, + Id = user.Result.Id, + IsDeleted = user.Result.IsDeleted, + IsUsernameVerified = true, + ModificationDateTime = user.Result.ModificationDateTime, + Password = user.Result.Password, + UniqueIdentity = user.Result.UniqueIdentity, + UserName = user.Result.UserName, + }); + if (!updateUser.IsSuccess) + return (FailedReasonType.Incorrect, "An error has occurred"); + return true; + } + return (FailedReasonType.Incorrect, "UserId is incorrect"); + } [HttpPost] public async Task> Register(AddUserRequestContract request) { @@ -51,7 +74,7 @@ public async Task> Login(UserSummaryContract request) return response; } - + [HttpPost] public async Task> GenerateToken(UserClaimContract request) diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/Program.cs b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/Program.cs index c5bd2c2..d9e4d58 100644 --- a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/Program.cs +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/Program.cs @@ -77,9 +77,9 @@ public static async Task Main(string[] args) }); - //builder.Services.AddDbContext(options => - // options.UseSqlServer(builder.Configuration.GetConnectionString(config.GetConnectionString("local"))) - //); + builder.Services.AddDbContext(options => + options.UseSqlServer(builder.Configuration.GetConnectionString(config.GetConnectionString("local"))) + ); //builder.Services.AddScoped((serviceProvider) => new DependencyManager().GetContractLogic()); string webRootPath = @Directory.GetCurrentDirectory(); @@ -131,7 +131,7 @@ public static async Task Main(string[] args) using (var scope = app.Services.CreateScope()) { using var context = scope.ServiceProvider.GetService(); - await context.Database.EnsureCreatedAsync(); + //await context.Database.EnsureCreatedAsync(); //await context.Database.MigrateAsync(); await context.DisposeAsync(); var service = scope.ServiceProvider.GetService(); diff --git a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/appsettings.Development.json b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/appsettings.Development.json index 7fca731..ce91bce 100644 --- a/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/appsettings.Development.json +++ b/src/CSharp/EasyMicroservices.AuthenticationsMicroservice.WebApi/appsettings.Development.json @@ -9,7 +9,8 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "local": "Server=.;Database=Authentications;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" + "local": "Server=.;Database=Authentications;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True", + }, "RootAddresses": { "whitelabel": "http://localhost:1041"