-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove idenitty grpc versioning. Remove EmailOptionsSetup in Idenity. Add Logic in SendConfirmationUserMessage in Email.Application project.
- Loading branch information
1 parent
7bf14d9
commit f9f2eb9
Showing
40 changed files
with
462 additions
and
147 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
2 changes: 1 addition & 1 deletion
2
...racts/Services/Identity/identity.v1.proto → ...ontracts/Services/Identity/identity.proto
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
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
5 changes: 4 additions & 1 deletion
5
...ication/Emails/Commands/SendConfirmationUserMessage/SendConfirmationUserMessageCommand.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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
namespace Email.Application.Emails.Commands.SendConfirmationUserMessage; | ||
|
||
public sealed record SendConfirmationUserMessageCommand(Guid UserId, string ReturnUrl) : ICommand; | ||
public sealed record SendConfirmationUserMessageCommand( | ||
Guid UserId, | ||
string ReturnUrl, | ||
string ConfirmationEmailToken) : ICommand; |
33 changes: 19 additions & 14 deletions
33
.../Emails/Commands/SendConfirmationUserMessage/SendConfirmationUserMessageCommandHandler.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 |
---|---|---|
@@ -1,25 +1,30 @@ | ||
namespace Email.Application.Emails.Commands.SendConfirmationUserMessage; | ||
using Email.Infrastructure.Email.Models; | ||
using Email.Infrastructure.Grpc.Idenitty; | ||
|
||
internal sealed class SendConfirmationUserMessageCommandHandler(IIdentityEmailService emailService) | ||
namespace Email.Application.Emails.Commands.SendConfirmationUserMessage; | ||
|
||
internal sealed class SendConfirmationUserMessageCommandHandler( | ||
IIdentityEmailService emailService, | ||
IIdentityGrpcService identityGrpcService) | ||
: ICommandHandler<SendConfirmationUserMessageCommand> | ||
{ | ||
private readonly IIdentityEmailService _emailService = emailService; | ||
private readonly IIdentityGrpcService _identityGrpcService = identityGrpcService; | ||
|
||
|
||
public Task<Result> Handle(SendConfirmationUserMessageCommand request, CancellationToken cancellationToken) | ||
public async Task<Result> Handle(SendConfirmationUserMessageCommand request, CancellationToken cancellationToken) | ||
{ | ||
var userInfo = await _identityGrpcService.GetUserInfoAsync(request.UserId, cancellationToken); | ||
|
||
var emailRequest = new SendConfirmationEmailRequest( | ||
userInfo.FirstName, | ||
userInfo.LastName, | ||
userInfo.UserId, | ||
userInfo.Email, | ||
request.ConfirmationEmailToken, | ||
request.ReturnUrl); | ||
|
||
await _emailService.SendConfirmationEmailAsync(emailRequest, cancellationToken); | ||
|
||
_emailService.SendConfirmationEmailAsync( | ||
new SendConfirmationEmailRequest | ||
{ | ||
UserId = request.UserId, | ||
EmailConfirmationToken = request.EmailConfirmationToken, | ||
ReturnUrl = request.ReturnUrl, | ||
FirstName = request.FirstName, | ||
LastName = request.LastName, | ||
Email = request.Email | ||
}, cancellationToken); | ||
return Result.Success(); | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
crs/Services/Email/Email.Infrastructure/Grpc/Idenitty/IIdentityGrpcService.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,6 @@ | ||
namespace Email.Infrastructure.Grpc.Idenitty; | ||
|
||
public interface IIdentityGrpcService | ||
{ | ||
public Task<UserInfo> GetUserInfoAsync(Guid id, CancellationToken cancellationToken = default); | ||
} |
14 changes: 14 additions & 0 deletions
14
crs/Services/Email/Email.Infrastructure/Grpc/Idenitty/IdentityGrpcService.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 static Identity.Protobuf.IdentityService; | ||
|
||
namespace Email.Infrastructure.Grpc.Idenitty; | ||
|
||
internal sealed class IdentityGrpcService(IdentityServiceClient client) : IIdentityGrpcService | ||
{ | ||
private readonly IdentityServiceClient _client = client; | ||
|
||
public async Task<UserInfo> GetUserInfoAsync(Guid id, CancellationToken cancellationToken = default) | ||
{ | ||
var request = new GetUserRequest() { Id = id.ToString() }; | ||
return await _client.GetUserInfoAsync(request, cancellationToken: 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
11 changes: 0 additions & 11 deletions
11
crs/Services/Identity/Identity.App/OptionsSetup/EmailOptionsSetup.cs
This file was deleted.
Oops, something went wrong.
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
6 changes: 3 additions & 3 deletions
6
...tity.Application/Users/Common/UserInfo.cs → ...ntity.Application/Users/Common/UserDto.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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
namespace Identity.Application.Users.Common; | ||
namespace Identity.Application.Users.Common; | ||
|
||
public sealed record UserInfo( | ||
public sealed record UserDto( | ||
Guid UserId, | ||
string Email, | ||
string FirstName, | ||
string LastName, | ||
bool IsEmailConfirmed, | ||
string Role, | ||
string Gender); | ||
string Gender); |
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
31 changes: 31 additions & 0 deletions
31
...es/Identity/Identity.Application/Users/Queries/GetUserInfoById/GetUserByIdQueryHandler.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,31 @@ | ||
namespace Identity.Application.Users.Queries.GetUserInfoById; | ||
|
||
internal sealed class GetUserByIdQueryHandler(IUserRepository userRepository) | ||
: IQueryHandler<GetUserInfoByIdQuery, UserDto> | ||
{ | ||
private readonly IUserRepository _userRepository = userRepository; | ||
|
||
public async Task<Result<UserDto>> Handle(GetUserInfoByIdQuery request, CancellationToken cancellationToken) | ||
{ | ||
var userId = new UserId(request.Id); | ||
|
||
var user = await _userRepository.GetUserByIdAsync(userId, cancellationToken); | ||
|
||
if (user is null) | ||
{ | ||
return Result.Failure<UserDto>( | ||
UserErrors.UserDoesNotExist); | ||
} | ||
|
||
var userInfo = new UserDto( | ||
user.Id.Value, | ||
user.Email.Value, | ||
user.FirstName.Value, | ||
user.LastName.Value, | ||
user.IsEmailConfirmed, | ||
user.Role.Name, | ||
user.Gender.Name); | ||
|
||
return Result.Success(userInfo); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...vices/Identity/Identity.Application/Users/Queries/GetUserInfoById/GetUserInfoByIdQuery.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Identity.Application.Users.Queries.GetUserInfoById; | ||
|
||
public sealed record GetUserInfoByIdQuery(Guid Id) : IQuery<UserInfo>; | ||
public sealed record GetUserInfoByIdQuery(Guid Id) : IQuery<UserDto>; | ||
|
Oops, something went wrong.