Browse Source

Added minimum password length to app.ini (#223)

tags/v1.1.0
Bwko 7 years ago
parent
commit
f27d87d93b
4 changed files with 17 additions and 4 deletions
  1. 2
    0
      conf/app.ini
  2. 6
    0
      modules/setting/setting.go
  3. 1
    1
      options/locale/locale_en-US.ini
  4. 8
    3
      routers/user/auth.go

+ 2
- 0
conf/app.ini View File

COOKIE_REMEMBER_NAME = gitea_incredible COOKIE_REMEMBER_NAME = gitea_incredible
; Reverse proxy authentication header name of user name ; Reverse proxy authentication header name of user name
REVERSE_PROXY_AUTHENTICATION_USER = X-WEBAUTH-USER REVERSE_PROXY_AUTHENTICATION_USER = X-WEBAUTH-USER
; Sets the minimum password length for new Users
MIN_PASSWORD_LENGTH = 6


[service] [service]
ACTIVE_CODE_LIVE_MINUTES = 180 ACTIVE_CODE_LIVE_MINUTES = 180

+ 6
- 0
modules/setting/setting.go View File

CookieUserName string CookieUserName string
CookieRememberName string CookieRememberName string
ReverseProxyAuthUser string ReverseProxyAuthUser string
MinPasswordLength int


// Database settings // Database settings
UseSQLite3 bool UseSQLite3 bool
CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome") CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible") CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER") ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt()

if MinPasswordLength == 0 {
MinPasswordLength = 6
}


sec = Cfg.Section("attachment") sec = Cfg.Section("attachment")
AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments")) AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))

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

reset_password = Reset Your Password reset_password = Reset Your Password
invalid_code = Sorry, your confirmation code has expired or not valid. invalid_code = Sorry, your confirmation code has expired or not valid.
reset_password_helper = Click here to reset your password reset_password_helper = Click here to reset your password
password_too_short = Password length cannot be less then 6.
password_too_short = Password length cannot be less then %d.
non_local_account = Non-local accounts cannot change passwords through Gitea. non_local_account = Non-local accounts cannot change passwords through Gitea.


[mail] [mail]

+ 8
- 3
routers/user/auth.go View File

ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplSignUp, &form) ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplSignUp, &form)
return return
} }
if len(form.Password) < setting.MinPasswordLength {
ctx.Data["Err_Password"] = true
ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplSignUp, &form)
return
}


u := &models.User{ u := &models.User{
Name: form.UserName, Name: form.UserName,
ctx.HTML(200, tplResetPassword) ctx.HTML(200, tplResetPassword)
} }


// ResetPasswdPost response fro reset password request
// ResetPasswdPost response from reset password request
func ResetPasswdPost(ctx *context.Context) { func ResetPasswdPost(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("auth.reset_password") ctx.Data["Title"] = ctx.Tr("auth.reset_password")


if u := models.VerifyUserActiveCode(code); u != nil { if u := models.VerifyUserActiveCode(code); u != nil {
// Validate password length. // Validate password length.
passwd := ctx.Query("password") passwd := ctx.Query("password")
if len(passwd) < 6 {
if len(passwd) < setting.MinPasswordLength {
ctx.Data["IsResetForm"] = true ctx.Data["IsResetForm"] = true
ctx.Data["Err_Password"] = true ctx.Data["Err_Password"] = true
ctx.RenderWithErr(ctx.Tr("auth.password_too_short"), tplResetPassword, nil)
ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplResetPassword, nil)
return return
} }



Loading…
Cancel
Save