public async Task SendEmail([FromBody] TwoFactorEmailRequestModel model)
        {
            var user = await CheckAsync(model.MasterPasswordHash, false);

            model.ToUser(user);
            await _userService.SendTwoFactorEmailAsync(user);
        }
Пример #2
0
        public async Task SendEmailLogin([FromBody] TwoFactorEmailRequestModel model)
        {
            var user = await _userManager.FindByEmailAsync(model.Email.ToLowerInvariant());

            if (user != null)
            {
                if (await _userService.VerifySecretAsync(user, model.Secret))
                {
                    var isBecauseNewDeviceLogin = false;
                    if (user.GetTwoFactorProvider(TwoFactorProviderType.Email) is null
                        &&
                        await _userService.Needs2FABecauseNewDeviceAsync(user, model.DeviceIdentifier, null))
                    {
                        model.ToUser(user);
                        isBecauseNewDeviceLogin = true;
                    }

                    await _userService.SendTwoFactorEmailAsync(user, isBecauseNewDeviceLogin);

                    return;
                }
            }

            await Task.Delay(2000);

            throw new BadRequestException("Cannot send two-factor email.");
        }
        public async Task SendEmailLogin([FromBody] TwoFactorEmailRequestModel model)
        {
            var user = await _userManager.FindByEmailAsync(model.Email.ToLowerInvariant());

            if (user != null)
            {
                if (await _userService.CheckPasswordAsync(user, model.MasterPasswordHash))
                {
                    await _userService.SendTwoFactorEmailAsync(user);

                    return;
                }
            }

            await Task.Delay(2000);

            throw new BadRequestException("Cannot send two-factor email.");
        }