Add auto-registration mechanism
- Add User registration mechanism when adding auth provider id to claims, if no User Id corresponds to the auth provider Id - Swallow unique constraint violation for unique auth provider id on user table, in case of duplicate requests - Add Serilog logging - Add no bookmarks and no tags message when none is found on Bookmark List page
This commit is contained in:
@ -24,6 +24,13 @@ namespace YABA.API.Middlewares
|
||||
if (!string.IsNullOrEmpty(userAuthProviderId))
|
||||
{
|
||||
var userId = userService.GetUserId(userAuthProviderId);
|
||||
|
||||
if(userId <= 0)
|
||||
{
|
||||
var registedUser = await userService.RegisterUser(userAuthProviderId);
|
||||
userId = registedUser.Id;
|
||||
}
|
||||
|
||||
httpContext.User.Identities.FirstOrDefault().AddClaim(new Claim(ClaimsLookup.UserId.GetClaimName(), userId.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user