mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-16 13:30:43 +08:00
ForgotPassword fix
This commit is contained in:
@@ -8,9 +8,12 @@ import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class MailOtpAuthn extends AbstractOptAuthn {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(MailOtpAuthn.class);
|
||||
|
||||
@Autowired
|
||||
EmailConfig emailConfig;
|
||||
|
||||
public MailOtpAuthn() {
|
||||
@@ -24,9 +27,10 @@ public class MailOtpAuthn extends AbstractOptAuthn {
|
||||
Email email = new SimpleEmail();
|
||||
email.setHostName(emailConfig.getSmtpHost());
|
||||
email.setSmtpPort(emailConfig.getPort());
|
||||
email.setSSLOnConnect(emailConfig.isSsl());
|
||||
email.setAuthenticator(
|
||||
new DefaultAuthenticator(emailConfig.getUsername(), emailConfig.getPassword()));
|
||||
email.setSSLOnConnect(emailConfig.isSsl());
|
||||
|
||||
email.setFrom(emailConfig.getSenderMail());
|
||||
email.setSubject("One Time PassWord");
|
||||
email.setMsg("You Token is " + token
|
||||
@@ -36,7 +40,12 @@ public class MailOtpAuthn extends AbstractOptAuthn {
|
||||
_logger.debug(
|
||||
"token " + token + " send to user +" + userInfo.getUsername()
|
||||
+ ", email " + userInfo.getEmail());
|
||||
//this.insertDataBase(userInfo, token, userInfo.getUsername(), OptTypes.EMAIL);
|
||||
//成功返回
|
||||
this.optTokenStore.store(
|
||||
userInfo,
|
||||
token,
|
||||
userInfo.getMobile(),
|
||||
OptTypes.EMAIL);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -46,7 +55,7 @@ public class MailOtpAuthn extends AbstractOptAuthn {
|
||||
|
||||
@Override
|
||||
public boolean validate(UserInfo userInfo, String token) {
|
||||
return true;
|
||||
return this.optTokenStore.validate(userInfo, token, OptTypes.EMAIL, interval);
|
||||
}
|
||||
|
||||
public void setEmailConfig(EmailConfig emailConfig) {
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package org.maxkey.domain;
|
||||
|
||||
|
||||
public class ForgotPassword extends ChangePassword{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1218071580331822219L;
|
||||
|
||||
/**
|
||||
* 1 for email
|
||||
* 2 for mobile sms code
|
||||
* 3 for answer question
|
||||
*/
|
||||
private int type;
|
||||
|
||||
private String email;
|
||||
|
||||
private String mobile;
|
||||
|
||||
private String smsCode;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ForgotPassword() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ForgotPassword(String email) {
|
||||
this.email=email;
|
||||
this.type=1;
|
||||
|
||||
}
|
||||
|
||||
public ForgotPassword(String mobile,String smsCode) {
|
||||
this.mobile=mobile;
|
||||
this.smsCode=smsCode;
|
||||
this.type=2;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the email
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param email the email to set
|
||||
*/
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getSmsCode() {
|
||||
return smsCode;
|
||||
}
|
||||
|
||||
public void setSmsCode(String smsCode) {
|
||||
this.smsCode = smsCode;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ForgotPassword [email=" + email + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user