Ejemplo n.º 1
0
        public async Task <TwoFactorEmailResponseModel> PutEmail([FromBody] UpdateTwoFactorEmailRequestModel model)
        {
            var user = await CheckAsync(model.MasterPasswordHash, false);

            model.ToUser(user);

            if (!await _userService.VerifyTwoFactorEmailAsync(user, model.Token))
            {
                await Task.Delay(2000);

                throw new BadRequestException("Token", "Invalid token.");
            }

            await _userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.Email);

            var response = new TwoFactorEmailResponseModel(user);

            return(response);
        }
Ejemplo n.º 2
0
        public async Task <TwoFactorEmailResponseModel> PutEmail([FromBody] UpdateTwoFactorEmailRequestModel model)
        {
            var user = await CheckAsync(model, false);

            model.ToUser(user);

            if (!await _userManager.VerifyTwoFactorTokenAsync(user,
                                                              CoreHelpers.CustomProviderName(TwoFactorProviderType.Email), model.Token))
            {
                await Task.Delay(2000);

                throw new BadRequestException("Token", "Invalid token.");
            }

            await _userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.Email);

            var response = new TwoFactorEmailResponseModel(user);

            return(response);
        }