去掉动态码登入
This commit is contained in:
1 parent
98657ace5b
commit
4dbc3e767b
5 files changed
+41
-26
No files matched your search
+1
-1
@@ -59,7 +59,7 @@ public class GoogleOauthController {
|
||||
@PostMapping("/exchange")
|
||||
public AjaxResult exchange(@RequestBody Map<String, String> request) {
|
||||
AjaxResult result = AjaxResult.success();
|
||||
result.put(Constants.TOKEN, googleOauthService.exchangeTicket(request.get("ticket")));
|
||||
result.put(Constants.TOKEN, googleOauthService.exchangeTicket(request.get("ticket"), request.get("totpCode")));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SysLoginController
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||
loginBody.getUuid(),true);
|
||||
loginBody.getUuid(),true, loginBody.getTotpCode());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class SysLoginController
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), null,
|
||||
loginBody.getUuid(),false);
|
||||
loginBody.getUuid(),false, loginBody.getTotpCode());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.TotpAuthService;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -13,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/** Authenticator 六位动态码;只有 login 匿名开放,管理接口使用当前 JWT 用户 ID。 */
|
||||
/** Authenticator 绑定管理;所有接口使用当前 JWT 用户 ID,不提供独立动态码登录。 */
|
||||
@RestController
|
||||
@RequestMapping("/auth/totp")
|
||||
public class TotpAuthController {
|
||||
@@ -47,21 +45,7 @@ public class TotpAuthController {
|
||||
return AjaxResult.success("Authenticator 已解绑");
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public AjaxResult login(@RequestBody TotpRequest request, HttpServletRequest servletRequest,
|
||||
HttpServletResponse response) {
|
||||
response.setHeader("Cache-Control", "no-store");
|
||||
AjaxResult result = AjaxResult.success();
|
||||
result.put(Constants.TOKEN, service.login(request.getUsername(), request.getTotpCode(),
|
||||
request.getCode(), request.getUuid(), servletRequest.getRemoteAddr()));
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 禁止生成包含密码、动态码的 toString;动态码与图形验证码分开传输。 */
|
||||
public static class TotpRequest extends LoginBody {
|
||||
private String totpCode;
|
||||
|
||||
public String getTotpCode() { return totpCode; }
|
||||
public void setTotpCode(String totpCode) { this.totpCode = totpCode; }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user