forked from Sichii/Chaos-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CredentialValidationResult.cs
78 lines (65 loc) · 2.23 KB
/
CredentialValidationResult.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
namespace Chaos.Security.Abstractions;
/// <summary>
/// Represents the result of a credential validation attempt
/// </summary>
public sealed class CredentialValidationResult
{
/// <summary>
/// The code that represents the result of the validation
/// </summary>
public enum FailureCode
{
/// <summary>
/// The validation succeeded
/// </summary>
Success,
/// <summary>
/// The validation failed because the provided username was invalid
/// </summary>
InvalidUsername,
/// <summary>
/// The validation failed because the provided password was invalid
/// </summary>
InvalidPassword,
/// <summary>
/// The validation failed because the provided password was too long
/// </summary>
PasswordTooLong,
/// <summary>
/// The validation failed because the provided password was too short
/// </summary>
PasswordTooShort,
/// <summary>
/// The validation failed because the provided username was too long
/// </summary>
UsernameTooLong,
/// <summary>
/// The validation failed because the provided username was too short
/// </summary>
UsernameTooShort,
/// <summary>
/// The validation failed because the provided username was not allowed
/// </summary>
UsernameNotAllowed,
/// <summary>
/// The validation failed because the ip has failed validation too many times
/// </summary>
TooManyAttempts
}
/// <summary>
/// The code that represents the result of the validation
/// </summary>
public FailureCode Code { get; init; }
/// <summary>
/// The message to display if the validation failed
/// </summary>
public string? FailureMessage { get; init; }
/// <summary>
/// The result of a successful credential validation
/// </summary>
public static CredentialValidationResult SuccessResult { get; } = new();
/// <summary>
/// Whether or not the validation succeeded
/// </summary>
public bool Success => string.IsNullOrEmpty(FailureMessage);
}