mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 访问授权码输入错误 3 次后加入验证码 https://github.com/siyuan-note/siyuan/issues/5429
This commit is contained in:
parent
724ab74566
commit
6ba35f09fc
2 changed files with 20 additions and 17 deletions
|
|
@ -466,7 +466,7 @@
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
authCode: inputElement.value,
|
authCode: inputElement.value,
|
||||||
captchaImg: captchaElement.value,
|
captcha: captchaElement.value,
|
||||||
}),
|
}),
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
|
||||||
|
|
@ -63,21 +63,19 @@ func LoginAuth(c *gin.Context) {
|
||||||
var inputCaptcha string
|
var inputCaptcha string
|
||||||
session := util.GetSession(c)
|
session := util.GetSession(c)
|
||||||
if session.NeedCaptcha() {
|
if session.NeedCaptcha() {
|
||||||
_ = inputCaptcha
|
captchaArg := arg["captcha"]
|
||||||
//captchaArg := arg["captcha"]
|
if nil == captchaArg {
|
||||||
//if nil == captchaArg {
|
ret.Code = 1
|
||||||
// c.Status(400)
|
ret.Msg = "need input captcha"
|
||||||
// ret.Code = -1
|
return
|
||||||
// ret.Msg = "need input captcha"
|
}
|
||||||
// return
|
inputCaptcha = captchaArg.(string)
|
||||||
//}
|
|
||||||
//inputCaptcha = captchaArg.(string)
|
if session.Captcha != inputCaptcha {
|
||||||
//
|
ret.Code = 1
|
||||||
//if session.Captcha != inputCaptcha {
|
ret.Msg = "invalid captcha"
|
||||||
// ret.Code = -1
|
return
|
||||||
// ret.Msg = "invalid captcha"
|
}
|
||||||
// return
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
authCode := arg["authCode"].(string)
|
authCode := arg["authCode"].(string)
|
||||||
|
|
@ -110,7 +108,12 @@ func LoginAuth(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCaptcha(c *gin.Context) {
|
func GetCaptcha(c *gin.Context) {
|
||||||
img, err := captcha.NewMathExpr(150, 30)
|
img, err := captcha.New(100, 26, func(options *captcha.Options) {
|
||||||
|
options.CharPreset = "abcdefghjkmnpqrtuvwxyz2346789"
|
||||||
|
options.Noise = 0.5
|
||||||
|
options.CurveNumber = 0
|
||||||
|
options.FontScale = 1.2
|
||||||
|
})
|
||||||
if nil != err {
|
if nil != err {
|
||||||
util.LogErrorf("generates captcha failed: " + err.Error())
|
util.LogErrorf("generates captcha failed: " + err.Error())
|
||||||
c.Status(500)
|
c.Status(500)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue