Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

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

Liang Ding091214f57396
diff --git a/README.md b/README.md
index 643896e1b5..1aaaaeae77 100644
--- a/README.md
+++ b/README.md
@@ -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`
diff --git a/README_zh_CN.md b/README_zh_CN.md
index 34b8c59499..e61203969b 100644
--- a/README_zh_CN.md
+++ b/README_zh_CN.md
@@ -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`
diff --git a/app/guide/20210808180117-6v0mkxr/20201121224345-rc27qvo.sy b/app/guide/20210808180117-6v0mkxr/20201121224345-rc27qvo.sy
index 5679955481..09be989f38 100644
--- a/app/guide/20210808180117-6v0mkxr/20201121224345-rc27qvo.sy
+++ b/app/guide/20210808180117-6v0mkxr/20201121224345-rc27qvo.sy
@@ -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",
diff --git a/app/guide/20210808180117-czj9bvb/20201121212605-9td1a62.sy b/app/guide/20210808180117-czj9bvb/20201121212605-9td1a62.sy
index d95e6653f5..416cc69dbc 100644
--- a/app/guide/20210808180117-czj9bvb/20201121212605-9td1a62.sy
+++ b/app/guide/20210808180117-czj9bvb/20201121212605-9td1a62.sy
@@ -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",
diff --git a/app/guide/20211226090932-5lcq56f/20211226114929-08ap1r0.sy b/app/guide/20211226090932-5lcq56f/20211226114929-08ap1r0.sy
index 3f81c76e49..0811393cb3 100644
--- a/app/guide/20211226090932-5lcq56f/20211226114929-08ap1r0.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226114929-08ap1r0.sy
@@ -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",
diff --git a/kernel/go.mod b/kernel/go.mod
index cf67502a0d..b4dc07f482 100644
--- a/kernel/go.mod
+++ b/kernel/go.mod
@@ -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
diff --git a/kernel/model/session.go b/kernel/model/session.go
index bdb550492a..0a634fdafe 100644
--- a/kernel/model/session.go
+++ b/kernel/model/session.go
@@ -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 {