-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from OpenMAVN/8-add-email-verification
#8 add email verification
- Loading branch information
Showing
49 changed files
with
1,262 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
client/MAVN.Service.AdminManagement.Client/Models/Enums/Localization.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace MAVN.Service.AdminManagement.Client.Models.Enums | ||
{ | ||
/// <summary>Localization</summary> | ||
public enum Localization | ||
{ | ||
/// <summary>En</summary> | ||
En = 0, | ||
/// <summary>De</summary> | ||
De | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
client/MAVN.Service.AdminManagement.Client/Models/Enums/VerificationCodeError.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace MAVN.Service.AdminManagement.Client.Models.Enums | ||
{ | ||
/// <summary> | ||
/// Enum for verification code errors. | ||
/// </summary> | ||
[PublicAPI] | ||
public enum VerificationCodeError | ||
{ | ||
/// <summary>ErrorCode: None</summary> | ||
None, | ||
/// <summary>ErrorCode: AlreadyVerified</summary> | ||
AlreadyVerified, | ||
/// <summary>ErrorCode: Verification code does not exist</summary> | ||
VerificationCodeDoesNotExist, | ||
/// <summary>ErrorCode: VerificationCodeMismatch</summary> | ||
VerificationCodeMismatch, | ||
/// <summary>ErrorCode: VerificationCodeExpired</summary> | ||
VerificationCodeExpired, | ||
/// <summary>Admin does not exist</summary> | ||
AdminDoesNotExist, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...anagement.Client/Models/Requests/Verification/VerificationCodeConfirmationRequestModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using JetBrains.Annotations; | ||
|
||
namespace MAVN.Service.AdminManagement.Client.Models.Requests.Verification | ||
{ | ||
/// <summary> | ||
/// Confirm verification code request model. | ||
/// </summary> | ||
[PublicAPI] | ||
public class VerificationCodeConfirmationRequestModel | ||
{ | ||
/// <summary>Verification code value</summary> | ||
[Required] | ||
public string VerificationCode { get; set; } | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...agement.Client/Models/Responses/Verification/VerificationCodeConfirmationResponseModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using JetBrains.Annotations; | ||
using MAVN.Service.AdminManagement.Client.Models.Enums; | ||
|
||
namespace MAVN.Service.AdminManagement.Client.Models.Responses.Verification | ||
{ | ||
/// <summary> | ||
/// ConfirmEmail response model. | ||
/// </summary> | ||
[PublicAPI] | ||
public class VerificationCodeConfirmationResponseModel | ||
{ | ||
/// <summary>Is verified</summary> | ||
public bool IsVerified { get; set; } | ||
|
||
/// <summary>Error</summary> | ||
public VerificationCodeError Error { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/MAVN.Service.AdminManagement.Domain/Enums/Localization.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace MAVN.Service.AdminManagement.Domain.Enums | ||
{ | ||
public enum Localization | ||
{ | ||
En = 0, | ||
De | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/MAVN.Service.AdminManagement.Domain/Enums/VerificationCodeError.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace MAVN.Service.AdminManagement.Domain.Enums | ||
{ | ||
public enum VerificationCodeError | ||
{ | ||
None, | ||
AlreadyVerified, | ||
VerificationCodeDoesNotExist, | ||
VerificationCodeMismatch, | ||
VerificationCodeExpired, | ||
AdminDoesNotExist, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/MAVN.Service.AdminManagement.Domain/Models/CallRateLimitSettingsDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace MAVN.Service.AdminManagement.Domain.Models | ||
{ | ||
public class CallRateLimitSettingsDto | ||
{ | ||
public int EmailVerificationMaxAllowedRequestsNumber { get; set; } | ||
public TimeSpan EmailVerificationCallsMonitoredPeriod { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/MAVN.Service.AdminManagement.Domain/Models/Emails/AdminCreatedEmailDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using MAVN.Service.AdminManagement.Domain.Enums; | ||
|
||
namespace MAVN.Service.AdminManagement.Domain.Models.Emails | ||
{ | ||
public class AdminCreatedEmailDto | ||
{ | ||
public string AdminUserId { get; set; } | ||
public string Email { get; set; } | ||
public string EmailVerificationCode { get; set; } | ||
public string Password { get; set; } | ||
public string Name { get; set; } | ||
public Localization Localization { get; set; } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/MAVN.Service.AdminManagement.Domain/Models/RegistrationRequestDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Collections.Generic; | ||
using MAVN.Service.AdminManagement.Domain.Enums; | ||
|
||
namespace MAVN.Service.AdminManagement.Domain.Models | ||
{ | ||
public class RegistrationRequestDto | ||
{ | ||
public string Email { get; set; } | ||
public string Password { get; set; } | ||
public string FirstName { get; set; } | ||
public string LastName { get; set; } | ||
public string PhoneNumber { get; set; } | ||
public string Company { get; set; } | ||
public string Department { get; set; } | ||
public string JobTitle { get; set; } | ||
public IReadOnlyList<Permission> Permissions { get; set; } | ||
public Localization Localization { get; set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
....Service.AdminManagement.Domain/Models/Verification/ConfirmVerificationCodeResultModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using MAVN.Service.AdminManagement.Domain.Enums; | ||
|
||
namespace MAVN.Service.AdminManagement.Domain.Models.Verification | ||
{ | ||
public class ConfirmVerificationCodeResultModel | ||
{ | ||
public bool IsVerified { get; set; } | ||
|
||
public VerificationCodeError Error { get; set; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/MAVN.Service.AdminManagement.Domain/Models/Verification/IVerificationCode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace MAVN.Service.AdminManagement.Domain.Models.Verification | ||
{ | ||
public interface IVerificationCode | ||
{ | ||
string AdminId { get; set; } | ||
|
||
string VerificationCode { get; set; } | ||
|
||
bool IsVerified { get; set; } | ||
|
||
DateTime ExpireDate { get; set; } | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/MAVN.Service.AdminManagement.Domain/Models/Verification/VerificationCodeResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using MAVN.Service.AdminManagement.Domain.Enums; | ||
|
||
namespace MAVN.Service.AdminManagement.Domain.Models.Verification | ||
{ | ||
public class VerificationCodeResult | ||
{ | ||
public VerificationCodeError Error { get; private set; } | ||
|
||
public DateTime? ExpiresAt { get; private set; } | ||
|
||
public static VerificationCodeResult Succeeded(DateTime expiresAt) | ||
{ | ||
return new VerificationCodeResult | ||
{ | ||
ExpiresAt = expiresAt | ||
}; | ||
} | ||
|
||
public static VerificationCodeResult Failed(VerificationCodeError error) | ||
{ | ||
return new VerificationCodeResult | ||
{ | ||
Error = error | ||
}; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/MAVN.Service.AdminManagement.Domain/Repositories/IEmailVerificationCodeRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Threading.Tasks; | ||
using MAVN.Service.AdminManagement.Domain.Models.Verification; | ||
|
||
namespace MAVN.Service.AdminManagement.Domain.Repositories | ||
{ | ||
public interface IEmailVerificationCodeRepository | ||
{ | ||
Task<IVerificationCode> CreateOrUpdateAsync(string adminId, string verificationCode); | ||
Task<IVerificationCode> GetByValueAsync(string value); | ||
Task SetAsVerifiedAsync(string value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/MAVN.Service.AdminManagement.Domain/Services/ICallRateLimiterService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace MAVN.Service.AdminManagement.Domain.Services | ||
{ | ||
public interface ICallRateLimiterService | ||
{ | ||
Task ClearAllCallRecordsForEmailVerificationAsync(string adminId); | ||
|
||
Task RecordEmailVerificationCallAsync(string adminId); | ||
|
||
Task<bool> IsAllowedToCallEmailVerificationAsync(string adminId); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/MAVN.Service.AdminManagement.Domain/Services/IEmailVerificationService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Threading.Tasks; | ||
using MAVN.Service.AdminManagement.Domain.Models.Verification; | ||
|
||
namespace MAVN.Service.AdminManagement.Domain.Services | ||
{ | ||
public interface IEmailVerificationService | ||
{ | ||
/// <summary> | ||
/// Confirms verification code | ||
/// </summary> | ||
/// <param name="verificationCode">Verification code value in base64 format</param> | ||
/// <returns></returns> | ||
Task<ConfirmVerificationCodeResultModel> ConfirmCodeAsync(string verificationCode); | ||
} | ||
} |
Oops, something went wrong.