🎨 访问授权码输入错误 3 次后加入验证码 https://github.com/siyuan-note/siyuan/issues/5429

This commit is contained in:
Liang Ding 2022-07-16 11:00:16 +08:00
parent b4208bbf36
commit 091214f573
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
7 changed files with 235 additions and 21 deletions

View file

@ -296,6 +296,7 @@ SiYuan is made possible by the following open source projects.
* [https://github.com/siyuan-note/encryption](https://github.com/siyuan-note/encryption) `Mulan PSL v2`
* [https://github.com/siyuan-note/filelock](https://github.com/siyuan-note/filelock) `Mulan PSL v2`
* [https://github.com/siyuan-note/httpclient](https://github.com/siyuan-note/httpclient) `Mulan PSL v2`
* [https://github.com/steambap/captcha](https://github.com/steambap/captcha) `MIT License`
* [https://github.com/vmihailenco/msgpack](https://github.com/vmihailenco/msgpack) `BSD-2-Clause License`
* [https://github.com/xrash/smetrics](https://github.com/xrash/smetrics) `MIT License`
* [https://github.com/microsoft/TypeScript](https://github.com/microsoft/TypeScript) `Apache-2.0 License`

View file

@ -305,6 +305,7 @@
* [https://github.com/siyuan-note/encryption](https://github.com/siyuan-note/encryption) `Mulan PSL v2`
* [https://github.com/siyuan-note/filelock](https://github.com/siyuan-note/filelock) `Mulan PSL v2`
* [https://github.com/siyuan-note/httpclient](https://github.com/siyuan-note/httpclient) `Mulan PSL v2`
* [https://github.com/steambap/captcha](https://github.com/steambap/captcha) `MIT License`
* [https://github.com/vmihailenco/msgpack](https://github.com/vmihailenco/msgpack) `BSD-2-Clause License`
* [https://github.com/xrash/smetrics](https://github.com/xrash/smetrics) `MIT License`
* [https://github.com/microsoft/TypeScript](https://github.com/microsoft/TypeScript) `Apache-2.0 License`

View file

@ -6,7 +6,7 @@
"id": "20201121224345-rc27qvo",
"title": "Acknowledgements",
"type": "doc",
"updated": "20220714213452"
"updated": "20220716105832"
},
"Children": [
{
@ -29,7 +29,7 @@
"ListData": {},
"Properties": {
"id": "20220522101213-z3hokh2",
"updated": "20220714213452"
"updated": "20220716105832"
},
"Children": [
{
@ -2831,6 +2831,76 @@
}
]
},
{
"ID": "20220716105829-vbod5lq",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20220716105829-vbod5lq",
"updated": "20220716105832"
},
"Children": [
{
"ID": "20220716105829-ogsmwn0",
"Type": "NodeParagraph",
"Properties": {
"id": "20220716105829-ogsmwn0",
"updated": "20220716105832"
},
"Children": [
{
"Type": "NodeLink",
"Data": "span",
"Children": [
{
"Type": "NodeOpenBracket"
},
{
"Type": "NodeLinkText",
"Data": "https://github.com/steambap/captcha"
},
{
"Type": "NodeCloseBracket"
},
{
"Type": "NodeOpenParen"
},
{
"Type": "NodeLinkDest",
"Data": "https://github.com/steambap/captcha"
},
{
"Type": "NodeCloseParen"
}
]
},
{
"Type": "NodeText",
"Data": " "
},
{
"Type": "NodeCodeSpan",
"Data": "code",
"Children": [
{
"Type": "NodeCodeSpanOpenMarker"
},
{
"Type": "NodeCodeSpanContent",
"Data": "MIT License"
},
{
"Type": "NodeCodeSpanCloseMarker"
}
]
}
]
}
]
},
{
"ID": "20220522101213-wxfscvi",
"Type": "NodeListItem",

View file

@ -6,7 +6,7 @@
"id": "20201121212605-9td1a62",
"title": "致谢",
"type": "doc",
"updated": "20220714214930"
"updated": "20220716105842"
},
"Children": [
{
@ -29,7 +29,7 @@
"ListData": {},
"Properties": {
"id": "20220522101224-ctmcj3d",
"updated": "20220714214930"
"updated": "20220716105842"
},
"Children": [
{
@ -2901,6 +2901,76 @@
}
]
},
{
"ID": "20220716105842-riuwgbq",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20220716105842-riuwgbq",
"updated": "20220716105842"
},
"Children": [
{
"ID": "20220716105842-c8od9nd",
"Type": "NodeParagraph",
"Properties": {
"id": "20220716105842-c8od9nd",
"updated": "20220716105842"
},
"Children": [
{
"Type": "NodeLink",
"Data": "span",
"Children": [
{
"Type": "NodeOpenBracket"
},
{
"Type": "NodeLinkText",
"Data": "https://github.com/steambap/captcha"
},
{
"Type": "NodeCloseBracket"
},
{
"Type": "NodeOpenParen"
},
{
"Type": "NodeLinkDest",
"Data": "https://github.com/steambap/captcha"
},
{
"Type": "NodeCloseParen"
}
]
},
{
"Type": "NodeText",
"Data": " "
},
{
"Type": "NodeCodeSpan",
"Data": "code",
"Children": [
{
"Type": "NodeCodeSpanOpenMarker"
},
{
"Type": "NodeCodeSpanContent",
"Data": "MIT License"
},
{
"Type": "NodeCodeSpanCloseMarker"
}
]
}
]
}
]
},
{
"ID": "20220522101224-4u2mzml",
"Type": "NodeListItem",

View file

@ -5,7 +5,7 @@
"icon": "1f64f",
"id": "20211226114929-08ap1r0",
"title": "致謝",
"updated": "20220714214924"
"updated": "20220716105852"
},
"Children": [
{
@ -28,7 +28,7 @@
"ListData": {},
"Properties": {
"id": "20220326092650-r61gazd",
"updated": "20220714214924"
"updated": "20220716105852"
},
"Children": [
{
@ -2900,6 +2900,76 @@
}
]
},
{
"ID": "20220716105851-g73ysy4",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20220716105851-g73ysy4",
"updated": "20220716105852"
},
"Children": [
{
"ID": "20220716105851-yzv7qyo",
"Type": "NodeParagraph",
"Properties": {
"id": "20220716105851-yzv7qyo",
"updated": "20220716105852"
},
"Children": [
{
"Type": "NodeLink",
"Data": "span",
"Children": [
{
"Type": "NodeOpenBracket"
},
{
"Type": "NodeLinkText",
"Data": "https://github.com/steambap/captcha"
},
{
"Type": "NodeCloseBracket"
},
{
"Type": "NodeOpenParen"
},
{
"Type": "NodeLinkDest",
"Data": "https://github.com/steambap/captcha"
},
{
"Type": "NodeCloseParen"
}
]
},
{
"Type": "NodeText",
"Data": " "
},
{
"Type": "NodeCodeSpan",
"Data": "code",
"Children": [
{
"Type": "NodeCodeSpanOpenMarker"
},
{
"Type": "NodeCodeSpanContent",
"Data": "MIT License"
},
{
"Type": "NodeCodeSpanCloseMarker"
}
]
}
]
}
]
},
{
"ID": "20220522101113-k9lx1nj",
"Type": "NodeListItem",

View file

@ -44,6 +44,7 @@ require (
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f
github.com/siyuan-note/filelock v0.0.0-20220704090116-54dfb035283f
github.com/siyuan-note/httpclient v0.0.0-20220709030145-2bfb50f28e73
github.com/steambap/captcha v1.4.1
github.com/vmihailenco/msgpack/v5 v5.3.5
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673
golang.org/x/image v0.0.0-20220617043117-41969df76e82
@ -107,7 +108,6 @@ require (
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/steambap/captcha v1.4.1 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
go.uber.org/atomic v1.9.0 // indirect

View file

@ -63,20 +63,21 @@ func LoginAuth(c *gin.Context) {
var inputCaptcha string
session := util.GetSession(c)
if session.NeedCaptcha() {
captchaArg := arg["captcha"]
if nil == captchaArg {
c.Status(400)
ret.Code = -1
ret.Msg = "need input captcha"
return
}
inputCaptcha = captchaArg.(string)
if session.Captcha != inputCaptcha {
ret.Code = -1
ret.Msg = "invalid captcha"
return
}
_ = inputCaptcha
//captchaArg := arg["captcha"]
//if nil == captchaArg {
// c.Status(400)
// ret.Code = -1
// ret.Msg = "need input captcha"
// return
//}
//inputCaptcha = captchaArg.(string)
//
//if session.Captcha != inputCaptcha {
// ret.Code = -1
// ret.Msg = "invalid captcha"
// return
//}
}
authCode := arg["authCode"].(string)
@ -98,6 +99,7 @@ func LoginAuth(c *gin.Context) {
return
}
session.AccessAuthCode = authCode
session.WrongAuthCount = 0
session.Captcha = gulu.Rand.String(7)
if err := session.Save(c); nil != err {