protected override async Task <IdentityUserLogin <string> > FindUserLoginAsync(string userId, string loginProvider, string providerKey, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); try { var ulc = UserLoginContainer.Create(userId, loginProvider, providerKey); var lookingForId = ulc.Payload.GetId(); return((await EnsureUserLoginAsync(ulc, cancellationToken)).Payload); } catch (Exception e) { logger.LogError(e, $"error FindUserLoginAsync user:{userId} "); throw; } }
protected async Task <UserLoginContainer> EnsureUserLoginAsync(UserLoginContainer userLoginContainer, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); var normalizedId = userLoginContainer.Payload.GetId(); try { var ulc = await identityDocumentStore.IdentitySession(async session => await session.LoadAsync <UserLoginContainer>(normalizedId, cancellationToken)); if (ulc == null) { await identityDocumentStore.IdentitySession(async session => await session.StoreAsync(userLoginContainer, normalizedId, cancellationToken)); return(await EnsureUserLoginAsync(userLoginContainer, cancellationToken)); } return(ulc); } catch (Exception e) { logger.LogError(e, $"error EnsureUserLoginAsync user:{normalizedId} "); throw; } }