做几方面优化
This commit is contained in:
@@ -81,6 +81,12 @@ func (c *AuthLoginController) LoginSubmit() {
|
||||
ClientID string `json:"client_id"`
|
||||
Redirect string `json:"redirect"`
|
||||
DeviceID string `json:"device_id"`
|
||||
// 极验 4.0 验证结果:开启人机验证后由前端 SDK 产出,验证通过才允许继续登录
|
||||
CaptchaID string `json:"captcha_id"`
|
||||
LotNumber string `json:"lot_number"`
|
||||
PassToken string `json:"pass_token"`
|
||||
GenTime string `json:"gen_time"`
|
||||
CaptchaOutput string `json:"captcha_output"`
|
||||
}
|
||||
|
||||
body := c.Ctx.Input.RequestBody
|
||||
@@ -101,6 +107,18 @@ func (c *AuthLoginController) LoginSubmit() {
|
||||
return
|
||||
}
|
||||
|
||||
// 开启人机验证时:先极验通过,再走账号密码校验
|
||||
if err := authsvc.VerifyLoginCaptcha(0, authsvc.CaptchaResult{
|
||||
CaptchaID: req.CaptchaID,
|
||||
LotNumber: req.LotNumber,
|
||||
PassToken: req.PassToken,
|
||||
GenTime: req.GenTime,
|
||||
CaptchaOutput: req.CaptchaOutput,
|
||||
}); err != nil {
|
||||
c.serveJSON(map[string]interface{}{"code": 400, "msg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
clientIP := c.Ctx.Input.IP()
|
||||
userAgent := c.Ctx.Request.UserAgent()
|
||||
|
||||
@@ -309,28 +327,31 @@ func (c *AuthLoginController) LogoutAction() {
|
||||
c.serveJSON(map[string]interface{}{"code": 200, "msg": "已登出"})
|
||||
}
|
||||
|
||||
// VerifyConfig 租户登录验证配置(替代 /backend/login/getOpenVerify)
|
||||
// VerifyConfig 登录验证配置(替代 /backend/login/getOpenVerify)
|
||||
// GET /auth/verify-config?tid=
|
||||
//
|
||||
// 登录页在选企业之前调用,tid 可为空:此时以平台全局配置为准。
|
||||
// 返回的人机验证信息供登录页决定是否在点击登录后弹出极验。
|
||||
func (c *AuthLoginController) VerifyConfig() {
|
||||
tid, _ := c.GetInt64("tid", 0)
|
||||
cfg := authsvc.GetTenantSessionPolicy(uint64(tid))
|
||||
sessionCfg := authsvc.GetTenantSessionPolicy(uint64(tid))
|
||||
verify := authsvc.GetLoginVerifyConfig(uint64(tid))
|
||||
|
||||
var authCfg models.AuthTenantAuthConfig
|
||||
verifyType := "captcha"
|
||||
openVerify := 1
|
||||
if err := models.Orm.QueryTable(new(models.AuthTenantAuthConfig)).
|
||||
Filter("tid", tid).One(&authCfg); err == nil {
|
||||
verifyType = authCfg.VerifyType
|
||||
openVerify = int(authCfg.OpenVerify)
|
||||
openVerify := 0
|
||||
if verify.OpenVerify {
|
||||
openVerify = 1
|
||||
}
|
||||
c.serveJSON(map[string]interface{}{
|
||||
"code": 200,
|
||||
"data": map[string]interface{}{
|
||||
"openVerify": openVerify,
|
||||
"verifyType": verifyType,
|
||||
"sessionTTL": cfg.SessionTTL,
|
||||
"maxSession": cfg.MaxSession,
|
||||
"mfaRequired": 0,
|
||||
"openVerify": openVerify,
|
||||
"verifyType": verify.VerifyType,
|
||||
"needGeetest": verify.NeedGeetest(),
|
||||
"geetestVersion": verify.GeetestVersion,
|
||||
"captchaId": verify.CaptchaID,
|
||||
"sessionTTL": sessionCfg.SessionTTL,
|
||||
"maxSession": sessionCfg.MaxSession,
|
||||
"mfaRequired": 0,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user