Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ValidateToken now returns username based of client usage #25

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -817,15 +817,15 @@ public virtual async System.Threading.Tasks.Task<GenerateResetPasswordTokenRespo

/// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<MessageContract> ValidateResetPasswordTokenAsync(ValidateResetPasswordTokenRequestContract body)
public virtual System.Threading.Tasks.Task<ValidateResetPasswordTokenResponseContractMessageContract> ValidateResetPasswordTokenAsync(ValidateResetPasswordTokenRequestContract body)
{
return ValidateResetPasswordTokenAsync(body, System.Threading.CancellationToken.None);
}

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<MessageContract> ValidateResetPasswordTokenAsync(ValidateResetPasswordTokenRequestContract body, System.Threading.CancellationToken cancellationToken)
public virtual async System.Threading.Tasks.Task<ValidateResetPasswordTokenResponseContractMessageContract> ValidateResetPasswordTokenAsync(ValidateResetPasswordTokenRequestContract body, System.Threading.CancellationToken cancellationToken)
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/ResetPassword/ValidateResetPasswordToken");
Expand Down Expand Up @@ -866,7 +866,7 @@ public virtual async System.Threading.Tasks.Task<MessageContract> ValidateResetP
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<MessageContract>(response_, headers_, cancellationToken).ConfigureAwait(false);
var objectResponse_ = await ReadObjectResponseAsync<ValidateResetPasswordTokenResponseContractMessageContract>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down Expand Up @@ -943,6 +943,35 @@
}
}
},
"ValidateResetPasswordTokenResponseContract": {
"type": "object",
"additionalProperties": false,
"properties": {
"userName": {
"type": "string",
"nullable": true
}
}
},
"ValidateResetPasswordTokenResponseContractMessageContract": {
"title": "MessageContract<ValidateResetPasswordTokenResponseContract>",
"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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<IsPackable>true</IsPackable>
<Version>0.0.0.9</Version>
<Version>0.0.0.10</Version>
<Description>client generated code.</Description>
<Copyright>EasyMicroservices@gmail.com</Copyright>
<PackageTags>microservice,Identity,Identity,client</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
@@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,11 +75,20 @@ await client.UpdateBulkChangedValuesOnlyAsync(new ResetPasswordTokenContractUpda

[HttpPost]
[AllowAnonymous]
public async Task<MessageContract> ValidateResetPasswordToken(ValidateResetPasswordTokenRequestContract request)
public async Task<MessageContract<ValidateResetPasswordTokenResponseContract>> ValidateResetPasswordToken(ValidateResetPasswordTokenRequestContract request)
{
var client = _appUnitOfWork.GetResetPasswordTokenClientClient();
var validateResponse = await client.GetValidTokenAsync(new GetValidTokenRequestContract { Token = request.Token });
return _appUnitOfWork.GetMapper().Map<MessageContract>(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]
Expand Down
Loading
Loading