ForgotPassword

This commit is contained in:
MaxKey
2022-04-25 22:00:45 +08:00
parent d6856b1f54
commit 7ddde38019
25 changed files with 599 additions and 160 deletions

View File

@@ -124,6 +124,32 @@ public class OtpAuthnService {
}
return otpAuthn;
}
public AbstractOtpAuthn getMailOtpAuthn(String instId) {
AbstractOtpAuthn otpAuthn = otpAuthnStore.getIfPresent(instId);
if(otpAuthn == null) {
EmailSenders emailSender =
emailSendersService.findOne("where instid = ? ", new Object[]{instId}, new int[]{Types.VARCHAR});
String credentials = PasswordReciprocal.getInstance().decoder(emailSender.getCredentials());
EmailConfig emailConfig =
new EmailConfig(
emailSender.getAccount(),
credentials,
emailSender.getSmtpHost(),
emailSender.getPort(),
ConstsBoolean.isTrue(emailSender.getSslSwitch()),
emailSender.getSender());
MailOtpAuthn mailOtpAuthn = new MailOtpAuthn(emailConfig);
mailOtpAuthn.setInterval(60 * 5);//5 minute
if(redisOptTokenStore != null) {
mailOtpAuthn.setOptTokenStore(redisOptTokenStore);
}
otpAuthn = mailOtpAuthn;
}
otpAuthnStore.put(instId, otpAuthn);
return otpAuthn;
}
public void setRedisOptTokenStore(RedisOtpTokenStore redisOptTokenStore) {
this.redisOptTokenStore = redisOptTokenStore;