From 091214f57396c443ad074c2fb8fd53b865783f73 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sat, 16 Jul 2022 11:00:16 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E8=AE=BF=E9=97=AE=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E7=A0=81=E8=BE=93=E5=85=A5=E9=94=99=E8=AF=AF=203=20=E6=AC=A1?= =?UTF-8?q?=E5=90=8E=E5=8A=A0=E5=85=A5=E9=AA=8C=E8=AF=81=E7=A0=81=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/5429?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + README_zh_CN.md | 1 + .../20201121224345-rc27qvo.sy | 74 ++++++++++++++++++- .../20201121212605-9td1a62.sy | 74 ++++++++++++++++++- .../20211226114929-08ap1r0.sy | 74 ++++++++++++++++++- kernel/go.mod | 2 +- kernel/model/session.go | 30 ++++---- 7 files changed, 235 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 643896e1b..1aaaaeae7 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 34b8c5949..e61203969 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 567995548..09be989f3 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 d95e6653f..416cc69db 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 3f81c76e4..0811393cb 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 cf67502a0..b4dc07f48 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 bdb550492..0a634fdaf 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 {