From cce0346b00811f38c2c5bb99dd0f36c3aeff55c8 Mon Sep 17 00:00:00 2001 From: Bo Wang Date: Sun, 24 Apr 2022 20:14:15 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E4=B8=AD=E5=87=BA=E7=8E=B0.=5F-=E8=BF=99=E4=BA=9B?= =?UTF-8?q?=E5=B8=B8=E7=94=A8=E7=9A=84=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/system/controllers/user.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/modules/system/controllers/user.go b/app/modules/system/controllers/user.go index 7f5bf18a..a0d18ca5 100644 --- a/app/modules/system/controllers/user.go +++ b/app/modules/system/controllers/user.go @@ -5,6 +5,7 @@ import ( "github.com/astaxie/beego/validation" "github.com/phachon/mm-wiki/app/models" "github.com/phachon/mm-wiki/app/utils" + "regexp" "strings" ) @@ -52,7 +53,7 @@ func (this *UserController) Save() { if username == "" { this.jsonError("用户名不能为空!") } - if !v.AlphaNumeric(username, "username").Ok { + if !v.Match(username, regexp.MustCompile("[a-zA-Z0-9.-_]+"), "match").Ok { this.jsonError("用户名格式不正确!") } if givenName == "" { From 290047b2a1055394d8b7fb43b0f4b6b3f1506230 Mon Sep 17 00:00:00 2001 From: Bo Wang Date: Sun, 24 Apr 2022 20:30:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0regexp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/system/controllers/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/modules/system/controllers/user.go b/app/modules/system/controllers/user.go index a0d18ca5..532e27df 100644 --- a/app/modules/system/controllers/user.go +++ b/app/modules/system/controllers/user.go @@ -53,7 +53,7 @@ func (this *UserController) Save() { if username == "" { this.jsonError("用户名不能为空!") } - if !v.Match(username, regexp.MustCompile("[a-zA-Z0-9.-_]+"), "match").Ok { + if !v.Match(username, regexp.MustCompile(`^[a-zA-Z0-9\.\-\_]+$`), "match").Ok { this.jsonError("用户名格式不正确!") } if givenName == "" { From 3f89089f9e3dbbc9306d3acff226cfd8c3d42f35 Mon Sep 17 00:00:00 2001 From: Bo Wang Date: Sun, 24 Apr 2022 20:36:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- views/system/user/form.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/system/user/form.html b/views/system/user/form.html index 0094eb5e..12efefeb 100644 --- a/views/system/user/form.html +++ b/views/system/user/form.html @@ -10,7 +10,7 @@
- * 只能由数字和字母组成 + * 只能由数字字母及 . _ - 组成