-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e25d9f4
commit 399ca28
Showing
10 changed files
with
76 additions
and
33 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
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
36 changes: 36 additions & 0 deletions
36
Source/Starfish.Service/Domain/Business/UserPasswordBusiness.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,36 @@ | ||
using System.Text.RegularExpressions; | ||
using Nerosoft.Euonia.Business; | ||
using Nerosoft.Euonia.Domain; | ||
using Nerosoft.Starfish.Service; | ||
|
||
namespace Nerosoft.Starfish.Domain; | ||
|
||
internal class UserPasswordBusiness : CommandObjectBase<UserPasswordBusiness>, IDomainService | ||
{ | ||
[Inject] | ||
public IUserRepository Repository { get; set; } | ||
|
||
[FactoryExecute] | ||
protected async Task ExecuteAsync(string id, string password, string actionType, CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrWhiteSpace(password)) | ||
{ | ||
throw new ValidationException(Resources.IDS_ERROR_USER_RULE_PASSWORD_REQUIRED); | ||
} | ||
else if (!Regex.IsMatch(password, Constants.RegexPattern.Password)) | ||
{ | ||
throw new ValidationException(Resources.IDS_ERROR_USER_RULE_PASSWORD_NOT_MARCHED_RULES); | ||
} | ||
|
||
var aggregate = await Repository.GetAsync(id, true, cancellationToken); | ||
|
||
if (aggregate == null) | ||
{ | ||
throw new UserNotFoundException(id); | ||
} | ||
|
||
aggregate.SetPassword(password, actionType); | ||
|
||
await Repository.UpdateAsync(aggregate, true, cancellationToken); | ||
} | ||
} |
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
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