Browse Source

Merge pull request '安全注册接口优化' (#213) from fix-179 into V20210731.patch

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/213
tags/v1.21.12.1
avadesian 4 years ago
parent
commit
6932e26730
7 changed files with 15 additions and 3 deletions
  1. +1
    -0
      modules/convert/convert.go
  2. +2
    -0
      modules/structs/user.go
  3. +1
    -1
      options/locale/locale_en-US.ini
  4. +1
    -0
      options/locale/locale_zh-CN.ini
  5. +1
    -1
      routers/routes/routes.go
  6. +8
    -0
      routers/secure/user.go
  7. +1
    -1
      templates/status/500.tmpl

+ 1
- 0
modules/convert/convert.go View File

@@ -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) {


+ 2
- 0
modules/structs/user.go View File

@@ -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


+ 1
- 1
options/locale/locale_en-US.ini View File

@@ -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 <strong>does not exist</strong> or <strong>you are not authorized</strong> to view it.
error500= Sorry, the site has encountered some problems, we are trying to <strong>fix the page</strong>, please try again later.
[error]
occurred = An error has occurred
report_message = An error has occurred


+ 1
- 0
options/locale/locale_zh-CN.ini View File

@@ -90,6 +90,7 @@ loading=正在加载...
error404_index = 您的访问受限!
error500_index = 抱歉!您指定的网页无法访问。
error404=您正尝试访问的页面 <strong>不存在</strong> 或 <strong>您尚未被授权</strong> 查看该页面。
error500=抱歉,站点遇到一些问题,我们正尝试<strong>修复网页</strong>,请您稍后再试。

[error]
occurred=发生错误


+ 1
- 1
routers/routes/routes.go View File

@@ -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() {


+ 8
- 0
routers/secure/user.go View File

@@ -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.


+ 1
- 1
templates/status/500.tmpl View File

@@ -6,7 +6,7 @@
<img class="ui centered medium image" src="{{StaticUrlPrefix}}/img/icon-500@2x.png">
<h2>{{.i18n.Tr "error500_index"}}</h2>
<p>{{.i18n.Tr "error404" | Safe}}</p>
<p>{{.i18n.Tr "error500" | Safe}}</p>
</div>
</div>


Loading…
Cancel
Save