Skip to content

Commit

Permalink
move IUserPasswordValidator to serenity
Browse files Browse the repository at this point in the history
  • Loading branch information
osmanaslancan committed Jul 25, 2023
1 parent 82310fe commit 6433614
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Security.Principal;

namespace Serenity.Abstractions;
namespace Serenity.Services;

/// <summary>
/// Default implementation for IUserClaimCreator
Expand Down
15 changes: 15 additions & 0 deletions src/Serenity.Net.Core/Authorization/IUserPasswordValidator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Serenity.Abstractions;

/// <summary>
/// Abstraction to validate a user password
/// </summary>
public interface IUserPasswordValidator
{
/// <summary>
/// Validates a user password
/// </summary>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns><see cref="PasswordValidationResult.Valid"/> if given username and password is true</returns>
PasswordValidationResult Validate(ref string username, string password);
}
40 changes: 40 additions & 0 deletions src/Serenity.Net.Core/Authorization/PasswordValidationResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Serenity.ComponentModel;

/// <summary>
/// Password validation result
/// </summary>
public enum PasswordValidationResult
{
/// <summary>
/// Username is empty
/// </summary>
EmptyUsername,
/// <summary>
/// Password is empty
/// </summary>
EmptyPassword,
/// <summary>
/// User is not active
/// </summary>
InactiveUser,
/// <summary>
/// User source is not found
/// </summary>
UnknownSource,
/// <summary>
/// To many retries
/// </summary>
Throttle,
/// <summary>
/// Directory error
/// </summary>
DirectoryError,
/// <summary>
/// Invalid
/// </summary>
Invalid,
/// <summary>
/// Valid
/// </summary>
Valid
}

0 comments on commit 6433614

Please sign in to comment.