From ced4611a20fcc6c67e163f1b3b803d3eee4afd67 Mon Sep 17 00:00:00 2001 From: MahdiyarGHD Date: Wed, 28 Feb 2024 20:34:42 +0330 Subject: [PATCH] Revert incorrect commit files --- .gitignore | 1 - .../IdentityGeneratedServices/OpenAPI.cs | 114 +++++++++++++++++- .../OpenAPI.nswag.json | 35 +++++- ...rvices.IdentityMicroservice.Clients.csproj | 2 +- ...idateResetPasswordTokenResponseContract.cs | 13 ++ .../Controllers/ResetPasswordController.cs | 14 ++- 6 files changed, 169 insertions(+), 10 deletions(-) create mode 100644 src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Responses/ValidateResetPasswordTokenResponseContract.cs diff --git a/.gitignore b/.gitignore index 07e6f0e..3fa877a 100644 --- a/.gitignore +++ b/.gitignore @@ -387,4 +387,3 @@ target/ # Dependency directories (remove the Identity below to include it) # vendor/ -/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/serilog.txt diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.cs index 73e75f6..6c55432 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.cs @@ -817,7 +817,7 @@ public virtual async System.Threading.Tasks.TaskSuccess /// A server side error occurred. - public virtual System.Threading.Tasks.Task ValidateResetPasswordTokenAsync(ValidateResetPasswordTokenRequestContract body) + public virtual System.Threading.Tasks.Task ValidateResetPasswordTokenAsync(ValidateResetPasswordTokenRequestContract body) { return ValidateResetPasswordTokenAsync(body, System.Threading.CancellationToken.None); } @@ -825,7 +825,7 @@ public virtual System.Threading.Tasks.Task ValidateResetPasswor /// 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 ValidateResetPasswordTokenAsync(ValidateResetPasswordTokenRequestContract body, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task ValidateResetPasswordTokenAsync(ValidateResetPasswordTokenRequestContract body, System.Threading.CancellationToken cancellationToken) { var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/ResetPassword/ValidateResetPasswordToken"); @@ -866,7 +866,7 @@ public virtual async System.Threading.Tasks.Task ValidateResetP var status_ = (int)response_.StatusCode; if (status_ == 200) { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + 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); @@ -2490,6 +2490,114 @@ 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 ValidateResetPasswordTokenResponseContract : System.ComponentModel.INotifyPropertyChanged + { + private string _userName; + + [Newtonsoft.Json.JsonProperty("userName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string UserName + { + get { return _userName; } + + set + { + if (_userName != value) + { + _userName = 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 ValidateResetPasswordTokenResponseContractMessageContract : System.ComponentModel.INotifyPropertyChanged + { + private bool _isSuccess; + private ErrorContract _error; + private SuccessContract _success; + private ValidateResetPasswordTokenResponseContract _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("success", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public SuccessContract Success + { + get { return _success; } + + set + { + if (_success != value) + { + _success = value; + RaisePropertyChanged(); + } + } + } + + [Newtonsoft.Json.JsonProperty("result", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public ValidateResetPasswordTokenResponseContract 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 ValidationContract : System.ComponentModel.INotifyPropertyChanged { diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.nswag.json b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.nswag.json index c5bc238..1601dc3 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.nswag.json +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/Connected Services/IdentityGeneratedServices/OpenAPI.nswag.json @@ -428,17 +428,17 @@ "content": { "text/plain": { "schema": { - "$ref": "#/components/schemas/MessageContract" + "$ref": "#/components/schemas/ValidateResetPasswordTokenResponseContractMessageContract" } }, "application/json": { "schema": { - "$ref": "#/components/schemas/MessageContract" + "$ref": "#/components/schemas/ValidateResetPasswordTokenResponseContractMessageContract" } }, "text/json": { "schema": { - "$ref": "#/components/schemas/MessageContract" + "$ref": "#/components/schemas/ValidateResetPasswordTokenResponseContractMessageContract" } } } @@ -943,6 +943,35 @@ } } }, + "ValidateResetPasswordTokenResponseContract": { + "type": "object", + "additionalProperties": false, + "properties": { + "userName": { + "type": "string", + "nullable": true + } + } + }, + "ValidateResetPasswordTokenResponseContractMessageContract": { + "title": "MessageContract", + "type": "object", + "additionalProperties": false, + "properties": { + "isSuccess": { + "type": "boolean" + }, + "error": { + "$ref": "#/components/schemas/ErrorContract" + }, + "success": { + "$ref": "#/components/schemas/SuccessContract" + }, + "result": { + "$ref": "#/components/schemas/ValidateResetPasswordTokenResponseContract" + } + } + }, "ValidationContract": { "type": "object", "additionalProperties": false, diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/EasyMicroservices.IdentityMicroservice.Clients.csproj b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/EasyMicroservices.IdentityMicroservice.Clients.csproj index f4682cf..25960e1 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/EasyMicroservices.IdentityMicroservice.Clients.csproj +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Clients/EasyMicroservices.IdentityMicroservice.Clients.csproj @@ -5,7 +5,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.9 + 0.0.0.10 client generated code. EasyMicroservices@gmail.com microservice,Identity,Identity,client diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Responses/ValidateResetPasswordTokenResponseContract.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Responses/ValidateResetPasswordTokenResponseContract.cs new file mode 100644 index 0000000..fb7702f --- /dev/null +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.Domain/Contracts/Responses/ValidateResetPasswordTokenResponseContract.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EasyMicroservices.IdentityMicroservice.Contracts.Responses +{ + public class ValidateResetPasswordTokenResponseContract + { + public string UserName { get; set; } + } +} diff --git a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Controllers/ResetPasswordController.cs b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Controllers/ResetPasswordController.cs index d2d8064..21d8b27 100644 --- a/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Controllers/ResetPasswordController.cs +++ b/src/CSharp/EasyMicroservices.IdentityMicroservice.WebApi/Controllers/ResetPasswordController.cs @@ -15,6 +15,7 @@ using System.Net; using System.Security.Claims; using System.Text; +using FailedReasonType = EasyMicroservices.ServiceContracts.FailedReasonType; using MessageContract = EasyMicroservices.ServiceContracts.MessageContract; namespace EasyMicroservices.IdentityMicroservice.WebApi.Controllers @@ -74,11 +75,20 @@ await client.UpdateBulkChangedValuesOnlyAsync(new ResetPasswordTokenContractUpda [HttpPost] [AllowAnonymous] - public async Task ValidateResetPasswordToken(ValidateResetPasswordTokenRequestContract request) + public async Task> ValidateResetPasswordToken(ValidateResetPasswordTokenRequestContract request) { var client = _appUnitOfWork.GetResetPasswordTokenClientClient(); var validateResponse = await client.GetValidTokenAsync(new GetValidTokenRequestContract { Token = request.Token }); - return _appUnitOfWork.GetMapper().Map(validateResponse); + if (!validateResponse.IsSuccess) + return (FailedReasonType.NotFound, "Token is not valid."); + + var user = await _appUnitOfWork.GetUserClient().GetByUniqueIdentityAsync(new GetByUniqueIdentityRequestContract + { + UniqueIdentity = DefaultUniqueIdentityManager.CutUniqueIdentity(validateResponse.Result.UniqueIdentity, 4), + Type = Authentications.GeneratedServices.GetUniqueIdentityType.Equals + }).AsCheckedResult(x => x.Result); + + return new ValidateResetPasswordTokenResponseContract { UserName = user.UserName }; } [HttpPost]