public virtual async Task <TwoFactorCodeSetup> GenerateCodeSetup(string secretKey, Customer customer, Language language, TwoFactorAuthenticationType twoFactorAuthenticationType) { var model = new TwoFactorCodeSetup(); switch (twoFactorAuthenticationType) { case TwoFactorAuthenticationType.AppVerification: var setupInfo = _twoFactorAuthentication.GenerateSetupCode(_storeContext.CurrentStore.CompanyName, customer.Email, secretKey, false, 3); model.CustomValues.Add("QrCodeImageUrl", setupInfo.QrCodeSetupImageUrl); model.CustomValues.Add("ManualEntryQrCode", setupInfo.ManualEntryKey); break; case TwoFactorAuthenticationType.EmailVerification: var token = PrepareRandomCode(); await _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.TwoFactorValidCode, token); await _genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.TwoFactorCodeValidUntil, DateTime.UtcNow.AddMinutes(30)); model.CustomValues.Add("Token", token); await _workflowMessageService.SendCustomerEmailTokenValidationMessage(customer, _storeContext.CurrentStore, language.Id); break; case TwoFactorAuthenticationType.SMSVerification: var smsVerificationService = _serviceProvider.GetRequiredService <ISMSVerificationService>(); model = await smsVerificationService.GenerateCode(secretKey, customer, language); break; default: break; } return(model); }
public virtual TwoFactorCodeSetup GenerateCodeSetup(string secretKey, string email) { var setupInfo = _twoFactorAuthentication.GenerateSetupCode(_storeContext.CurrentStore.CompanyName, email, secretKey, false, 3); var model = new TwoFactorCodeSetup(); model.CustomValues.Add("QrCodeImageUrl", setupInfo.QrCodeSetupImageUrl); model.CustomValues.Add("ManualEntryQrCode", setupInfo.ManualEntryKey); return(model); }