mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-15 04:52:09 +08:00
onetimepwd login
This commit is contained in:
@@ -5,6 +5,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.maxkey.configuration.EmailConfig;
|
||||
import org.maxkey.constants.ConstsBoolean;
|
||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.maxkey.entity.EmailSenders;
|
||||
import org.maxkey.entity.SmsProvider;
|
||||
import org.maxkey.password.onetimepwd.impl.MailOtpAuthn;
|
||||
@@ -84,10 +85,12 @@ public class OtpAuthnService {
|
||||
}else if(smsProvider.getProvider().equalsIgnoreCase("email")) {
|
||||
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(),
|
||||
emailSender.getCredentials(),
|
||||
credentials,
|
||||
emailSender.getSmtpHost(),
|
||||
emailSender.getPort(),
|
||||
ConstsBoolean.isTrue(emailSender.getSslSwitch()),
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.entity.Institutions;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
|
||||
import org.maxkey.password.onetimepwd.OtpAuthnService;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
@@ -82,9 +83,9 @@ public class LoginEndpoint {
|
||||
@Qualifier("tfaOtpAuthn")
|
||||
protected AbstractOtpAuthn tfaOtpAuthn;
|
||||
|
||||
//@Autowired
|
||||
//@Qualifier("smsOtpAuthn")
|
||||
protected AbstractOtpAuthn smsOtpAuthn;
|
||||
@Autowired
|
||||
@Qualifier("otpAuthnService")
|
||||
protected OtpAuthnService otpAuthnService;
|
||||
|
||||
Pattern mobileRegex = Pattern.compile(
|
||||
"^(13[4,5,6,7,8,9]|15[0,8,9,1,7]|188|187)\\\\d{8}$");
|
||||
@@ -168,10 +169,10 @@ public class LoginEndpoint {
|
||||
|
||||
@RequestMapping("/login/sendsms/{mobile}")
|
||||
@ResponseBody
|
||||
public String produceOtp(@PathVariable("mobile") String mobile) {
|
||||
public String produceOtp(@PathVariable("mobile") String mobile,HttpServletRequest request) {
|
||||
UserInfo queryUserInfo=userInfoService.findByEmailMobile(mobile);
|
||||
if(queryUserInfo!=null) {
|
||||
smsOtpAuthn.produce(queryUserInfo);
|
||||
otpAuthnService.getByInstId(WebContext.getInst(request)).produce(queryUserInfo);
|
||||
return "ok";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var currentSwitchTab="normalLogin";
|
||||
function doLoginSubmit(){
|
||||
currentSwitchTab = $(".switch_tab_current").attr("id") ;
|
||||
$.cookie("mxk_login_username", $("#"+currentSwitchTab+"Form input[name=username]").val(), { expires: 7 });
|
||||
$("#"+currentSwitchTab+"SubmitButton").click();
|
||||
$.cookie("mxk_login_switch_tab", currentSwitchTab, { expires: 7 });
|
||||
|
||||
Reference in New Issue
Block a user