From ac942c95f80c425647e217621a1ee3a7e8f2e55d Mon Sep 17 00:00:00 2001 From: hit172587zpz Date: Wed, 4 Aug 2021 10:09:43 +0800 Subject: [PATCH 1/4] fix issue-183 --- options/locale/locale_en-US.ini | 2 +- options/locale/locale_zh-CN.ini | 1 + templates/status/500.tmpl | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index e809a33e8..b81dc9694 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -90,7 +90,7 @@ loading = Loading… error404_index = Request forbidden by administrative rules error500_index = Internal Server Error error404 = The page you are trying to reach either does not exist or you are not authorized to view it. - +error500= Sorry, the site has encountered some problems, we are trying to fix the page, please try again later. [error] occurred = An error has occurred report_message = An error has occurred diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 9747bc7dc..5ac54f6c8 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -90,6 +90,7 @@ loading=正在加载... error404_index = 您的访问受限! error500_index = 抱歉!您指定的网页无法访问。 error404=您正尝试访问的页面 不存在您尚未被授权 查看该页面。 +error500=抱歉,站点遇到一些问题,我们正尝试修复网页,请您稍后再试。 [error] occurred=发生错误 diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl index e4ea06d3d..ca7336f82 100644 --- a/templates/status/500.tmpl +++ b/templates/status/500.tmpl @@ -6,7 +6,7 @@

{{.i18n.Tr "error500_index"}}

-

{{.i18n.Tr "error404" | Safe}}

+

{{.i18n.Tr "error500" | Safe}}

From cad94c529c4b190efbffcb32fd04519021cbd95b Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 4 Aug 2021 14:33:21 +0800 Subject: [PATCH 2/4] fix --- modules/convert/convert.go | 1 + modules/structs/user.go | 2 ++ 2 files changed, 3 insertions(+) mode change 100644 => 100755 modules/convert/convert.go mode change 100644 => 100755 modules/structs/user.go diff --git a/modules/convert/convert.go b/modules/convert/convert.go old mode 100644 new mode 100755 index ec18b1305..fa2e8f2e7 --- a/modules/convert/convert.go +++ b/modules/convert/convert.go @@ -335,6 +335,7 @@ func ToUser(user *models.User, signed, authed bool) *api.User { AvatarURL: user.AvatarLink(), FullName: markup.Sanitize(user.FullName), Created: user.CreatedUnix.AsTime(), + IsActive: user.IsActive, } // hide primary email if API caller is anonymous or user keep email private if signed && (!user.KeepEmailPrivate || authed) { diff --git a/modules/structs/user.go b/modules/structs/user.go old mode 100644 new mode 100755 index bf52cc9ed..d6e7298cc --- a/modules/structs/user.go +++ b/modules/structs/user.go @@ -26,6 +26,8 @@ type User struct { Language string `json:"language"` // Is the user an administrator IsAdmin bool `json:"is_admin"` + // Is the user active + IsActive bool `json:"is_active"` // swagger:strfmt date-time LastLogin time.Time `json:"last_login,omitempty"` // swagger:strfmt date-time From f1ef62479d1443a1d4e1f0f78c2750a56faf03c9 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 4 Aug 2021 17:35:37 +0800 Subject: [PATCH 3/4] mod err msg --- routers/routes/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 100ff009f..b3565878e 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -1129,7 +1129,7 @@ func RegisterRoutes(m *macaron.Macaron) { //secure api, m.Group("/secure", func() { - m.Post("/user", binding.Bind(structs.CreateUserOption{}), secure.CreateUser) + m.Post("/user", binding.BindIgnErr(structs.CreateUserOption{}), secure.CreateUser) }, reqBasicAuth) m.Group("/api/internal", func() { From 2c93a0a02905869617be6bbc7d260c3500727b4d Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Fri, 6 Aug 2021 11:18:38 +0800 Subject: [PATCH 4/4] optimization of secure register --- routers/secure/user.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routers/secure/user.go b/routers/secure/user.go index 1e88a7381..808761d06 100755 --- a/routers/secure/user.go +++ b/routers/secure/user.go @@ -119,6 +119,14 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) { return } + // Send confirmation email + if setting.Service.RegisterEmailConfirm{ + mailer.SendActivateAccountMail(ctx.Locale, u) + if err := ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil { + log.Error("Set cache(MailResendLimit) fail: %v", err) + } + } + log.Trace("Account created (%s): %s", ctx.User.Name, u.Name, ctx.Data["MsgID"]) // Send email notification.