public async Task ExecuteAsync(UserIdentitiesData input, CacheItem relatedItem)
        {
            var recoveryToken = !string.IsNullOrEmpty(input.RecoveryData) ? Guid.NewGuid().ToString("N") : null;

            // Credentials created at web app
            if (input.ActualChallengeType.HasValue && input.ActualChallengeType != relatedItem.ChallengeType)
            {
                relatedItem.ChallengeType = input.ActualChallengeType.Value;
            }
            // check if users exists or not. If not - then this is LinkOnLogin
            else if (relatedItem.ChallengeType == ChallengeType.Login)
            {
                var isUserExists = await _userHandlerAdapter.IsUserExistsAsync(input.PublicKey);

                if (!isUserExists)
                {
                    relatedItem.ChallengeType = ChallengeType.LinkOnLogin;
                }
            }

            await _cacheItemRepository.UpdateAsync(relatedItem.Context, item =>
            {
                item.ChallengeType = relatedItem.ChallengeType;
                item.RecoveryToken = recoveryToken;
                item.RecoveryData  = input.RecoveryData;
                item.FinishFlow(input.DID, input.PublicKey);
            });
        }
Ejemplo n.º 2
0
        private async Task <ITransitionResult> FinishAuthProcessAsync(UserIdentitiesData userData, CacheItem relatedItem,
                                                                      TransitionInput <JwtContainer> input)
        {
            await _savePartialConnectionCommand.ExecuteAsync(userData, relatedItem);

            var composeInfo = new BaseJwtComposeInfo(input)
            {
                Behavior = FrontendBehavior.CreateSuccessFinish(relatedItem.ChallengeType)
            };

            var jwt = JwtComposer.GenerateFinalStepJwt(composeInfo);

            return(new StateResult(jwt, _cookieService.CreateAuthCookies(relatedItem)));
        }