Integration
The Identity Service manage some events when a UserIdentity entity is
modified, as well as a message that can be published.
We need to reference the Identity Service project, as it's shown below:
C# |
---|
| <ProjectReference Include="$(ServicesPath)Identity\ITsynch.Suite.Identity.Application.Contracts\ITsynch.Suite.Identity.Application.Contracts.csproj" />
|
Messages
Identity Service provides a message to change the User password,
ChangePasswordUserIdentity:
C# |
---|
| var newPassword = "!myNewPassword001";
var loginId = "myLoginId";
await this.PublishEndpoint.Publish<ChangePasswordUserIdentity>(new
{
CorrelationId = correlationId,
NewPassword = newPassword,
LoginId = loginId
});
|
Events
You can consume the Identity's events and perform the actions you need to do in
your project.
UserIdentityUpdated: Published when the UserIdentity is created or
updated. It contains the CorrelationId and LoginId.
C# |
---|
| using ITsynch.Suite.Identity.Application;
using MassTransit;
using System.Threading.Tasks;
namespace ITsynch.Suite.Example.Application
{
public class UserIdentityUpdatedConsumer : IConsumer<UserIdentityUpdated>
{
public UserIdentityUpdatedConsumer()
{
}
public async Task Consume(ConsumeContext<UserIdentityUpdated> context)
{
// do some stuff
}
}
}
|
UserIdentityPasswordChanged: Published when the UserIdentity password is
changed. It contains the CorrelationId and LoginId.
C# |
---|
| using ITsynch.Suite.Identity.Application;
using MassTransit;
using System.Threading.Tasks;
namespace ITsynch.Suite.Example.Application
{
public class UserIdentityPasswordChangedConsumer : IConsumer<UserIdentityPasswordChanged>
{
public UserIdentityPasswordChangedConsumer()
{
}
public async Task Consume(ConsumeContext<UserIdentityPasswordChanged> context)
{
// do some stuff
}
}
}
|
UserIdentityDeleted: Published when the UserIdentity is deleted. It
contains the CorrelationId.
C# |
---|
| using ITsynch.Suite.Identity.Application;
using MassTransit;
using System.Threading.Tasks;
namespace ITsynch.Suite.Example.Application
{
public class UserIdentityDeletedConsumer : IConsumer<UserIdentityDeleted>
{
public UserIdentityDeletedConsumer()
{
}
public async Task Consume(ConsumeContext<UserIdentityDeleted> context)
{
// do some stuff
}
}
}
|