-
Hey ! I'm new using this library, and I'm currently trying to build a simple api with indivdual accounts authentication (with Asp.NET Core Identity Provider). Basically, I've been wondering for a while how are the identity provider & AuthP's dbs syncing together, that's where I found SyncAndShowChangesAsync & ApplySyncChangesAsync. And here comes my question, does this sync code works in order to add/update/delete roles that have been handled on the Identity provider side. In other words, and with a few lines of code, imagine I just want to add a role to an IdentityUser during a verify user email process and to reflect this change into AuthP's db: private readonly UserManager<IdentityUser> _userManager;
private readonly IAuthUsersAdminService _authUsersAdmin;
public VerifyEmailEndpoint(UserManager<IdentityUser> userManager, IAuthUsersAdminService authUsersAdmin)
{
_userManager = userManager;
_authUsersAdmin = authUsersAdmin;
}
public async Task HandleAsync(string id) {
IdentityUser? user = await _userManager.FindByIdAsync(id);
await _userManager.AddToRoleAsync(user, RoleType.User.ToString());
// Is this the right way to do it, with IAuthUsersAdminService.UpdateUserAsync ? Or should I use the sync code ?
await _authUsersAdmin.UpdateUserAsync(user?.Id, roleNames: new List<string> { RoleType.User.ToString() });
} Is this the right way to do it, or should I use the sync code ? Finally, when should I use the AuthP sync code ? Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @Tusquito, You might find the article Three ways to securely add new users to an application using the AuthP library which gives you three ways you can set up the AuthP's AuthUser and the pros and cons of each approach. Also the AuthP's documentation has lots of useful information - try Setup Authentication as a starting point. |
Beta Was this translation helpful? Give feedback.
Hi @Tusquito,
You might find the article Three ways to securely add new users to an application using the AuthP library which gives you three ways you can set up the AuthP's AuthUser and the pros and cons of each approach. Also the AuthP's documentation has lots of useful information - try Setup Authentication as a starting point.