Skip to content

Commit

Permalink
Return obsolete classes
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-dudarev committed Jul 3, 2024
1 parent 73f01ae commit 900d3a0
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using VirtoCommerce.Platform.Core.Security;

namespace VirtoCommerce.Platform.Security.Model
{
[Obsolete("Use VirtoCommerce.Platform.Security.OpenIddict.TokenRequestContext", DiagnosticId = "VC0008", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")]
public class SignInValidatorContext
{
public ApplicationUser User { get; set; }

public string StoreId { get; set; }

public bool DetailedErrors { get; set; }

public bool IsSucceeded { get; set; }

public bool IsLockedOut { get; set; }

public IDictionary<string, object> AdditionalParameters { get; set; } = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
}
}
30 changes: 30 additions & 0 deletions src/VirtoCommerce.Platform.Security/Model/TokenLoginResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Identity;
using OpenIddict.Abstractions;

namespace VirtoCommerce.Platform.Security.Model
{
[Obsolete("Use VirtoCommerce.Platform.Security.OpenIddict.TokenResponse", DiagnosticId = "VC0008", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")]
public class TokenLoginResponse : OpenIddictResponse
{
public string UserId { get; set; }

public IList<IdentityError> Errors
{
get
{
var errors = new List<IdentityError>();
if (Code != null)
{
errors.Add(new IdentityError
{
Code = Code,
Description = ErrorDescription
});
}
return errors;
}
}
}
}
74 changes: 74 additions & 0 deletions src/VirtoCommerce.Platform.Security/SecurityErrorDescriber.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using VirtoCommerce.Platform.Core.Common;
using VirtoCommerce.Platform.Security.Model;
using static OpenIddict.Abstractions.OpenIddictConstants;

namespace VirtoCommerce.Platform.Security
{
[Obsolete("Use VirtoCommerce.Platform.Security.OpenIddict.SecurityErrorDescriber", DiagnosticId = "VC0008", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")]
public static class SecurityErrorDescriber
{
public static TokenLoginResponse LoginFailed() => new()
{
Error = Errors.InvalidGrant,
Code = nameof(LoginFailed).ToSnakeCase(),
ErrorDescription = "Login attempt failed. Please check your credentials."
};

public static TokenLoginResponse UserIsLockedOut() => new()
{
Error = Errors.InvalidGrant,
Code = nameof(UserIsLockedOut).ToSnakeCase(),
ErrorDescription = "Your account has been locked. Please contact support for assistance."
};

public static TokenLoginResponse UserIsTemporaryLockedOut() => new()
{
Error = Errors.InvalidGrant,
Code = nameof(UserIsLockedOut).ToSnakeCase(),
ErrorDescription = "Your account has been temporarily locked. Please try again after some time."
};

public static TokenLoginResponse PasswordExpired() => new()
{
Error = Errors.InvalidGrant,
Code = nameof(PasswordExpired).ToSnakeCase(),
ErrorDescription = "Your password has been expired and must be changed.",
};

public static TokenLoginResponse PasswordLoginDisabled() => new()
{
Error = Errors.InvalidGrant,
Code = nameof(PasswordLoginDisabled).ToSnakeCase(),
ErrorDescription = "The username/password login is disabled."
};

public static TokenLoginResponse TokenInvalid() => new()
{
Error = Errors.InvalidGrant,
Code = nameof(TokenInvalid).ToSnakeCase(),
ErrorDescription = "The token is no longer valid."
};

public static TokenLoginResponse SignInNotAllowed() => new()
{
Error = Errors.InvalidGrant,
Code = nameof(SignInNotAllowed).ToSnakeCase(),
ErrorDescription = "The user is no longer allowed to sign in."
};

public static TokenLoginResponse InvalidClient() => new()
{
Error = Errors.InvalidClient,
Code = nameof(InvalidClient).ToSnakeCase(),
ErrorDescription = "The client application was not found in the database."
};

public static TokenLoginResponse UnsupportedGrantType() => new()
{
Error = Errors.UnsupportedGrantType,
Code = nameof(UnsupportedGrantType).ToSnakeCase(),
ErrorDescription = "The specified grant type is not supported."
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using VirtoCommerce.Platform.Security.Model;

namespace VirtoCommerce.Platform.Security.Services
{
[Obsolete("Use VirtoCommerce.Platform.Security.OpenIddict.ITokenRequestValidator", DiagnosticId = "VC0008", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")]
public interface IUserSignInValidator
{
public int Priority { get; set; }

Task<IList<TokenLoginResponse>> ValidateUserAsync(SignInValidatorContext context);
}
}

0 comments on commit 900d3a0

Please sign in to comment.