diff options
Diffstat (limited to 'internal/route')
-rw-r--r-- | internal/route/admin/admin.go | 3 | ||||
-rw-r--r-- | internal/route/api/v1/user/email.go | 4 | ||||
-rw-r--r-- | internal/route/dev/template.go | 4 | ||||
-rw-r--r-- | internal/route/home.go | 2 | ||||
-rw-r--r-- | internal/route/install.go | 10 | ||||
-rw-r--r-- | internal/route/repo/http.go | 2 | ||||
-rw-r--r-- | internal/route/repo/setting.go | 4 | ||||
-rw-r--r-- | internal/route/user/auth.go | 24 | ||||
-rw-r--r-- | internal/route/user/setting.go | 6 |
9 files changed, 30 insertions, 29 deletions
diff --git a/internal/route/admin/admin.go b/internal/route/admin/admin.go index 1722c373..a5217875 100644 --- a/internal/route/admin/admin.go +++ b/internal/route/admin/admin.go @@ -203,12 +203,13 @@ func Config(c *context.Context) { c.Data["Database"] = conf.Database c.Data["Security"] = conf.Security c.Data["Email"] = conf.Email + c.Data["Auth"] = conf.Auth + c.Data["User"] = conf.User c.Data["LogRootPath"] = conf.LogRootPath c.Data["HTTP"] = conf.HTTP - c.Data["Service"] = conf.Service c.Data["Webhook"] = conf.Webhook c.Data["CacheAdapter"] = conf.CacheAdapter diff --git a/internal/route/api/v1/user/email.go b/internal/route/api/v1/user/email.go index b45c716d..e211221c 100644 --- a/internal/route/api/v1/user/email.go +++ b/internal/route/api/v1/user/email.go @@ -10,9 +10,9 @@ import ( api "github.com/gogs/go-gogs-client" + "gogs.io/gogs/internal/conf" "gogs.io/gogs/internal/context" "gogs.io/gogs/internal/db" - "gogs.io/gogs/internal/conf" ) func ListEmails(c *context.APIContext) { @@ -39,7 +39,7 @@ func AddEmail(c *context.APIContext, form api.CreateEmailOption) { emails[i] = &db.EmailAddress{ UID: c.User.ID, Email: form.Emails[i], - IsActivated: !conf.Service.RegisterEmailConfirm, + IsActivated: !conf.Auth.RequireEmailConfirmation, } } diff --git a/internal/route/dev/template.go b/internal/route/dev/template.go index daa8e8f4..b7392580 100644 --- a/internal/route/dev/template.go +++ b/internal/route/dev/template.go @@ -16,8 +16,8 @@ func TemplatePreview(c *context.Context) { c.Data["AppVersion"] = conf.App.Version c.Data["AppURL"] = conf.Server.ExternalURL c.Data["Code"] = "2014031910370000009fff6782aadb2162b4a997acb69d4400888e0b9274657374" - c.Data["ActiveCodeLives"] = conf.Service.ActiveCodeLives / 60 - c.Data["ResetPwdCodeLives"] = conf.Service.ResetPwdCodeLives / 60 + c.Data["ActiveCodeLives"] = conf.Auth.ActivateCodeLives / 60 + c.Data["ResetPwdCodeLives"] = conf.Auth.ResetPasswordCodeLives / 60 c.Data["CurDbValue"] = "" c.HTML(200, (c.Params("*"))) diff --git a/internal/route/home.go b/internal/route/home.go index d64512c1..5906f8bb 100644 --- a/internal/route/home.go +++ b/internal/route/home.go @@ -22,7 +22,7 @@ const ( func Home(c *context.Context) { if c.IsLogged { - if !c.User.IsActive && conf.Service.RegisterEmailConfirm { + if !c.User.IsActive && conf.Auth.RequireEmailConfirmation { c.Data["Title"] = c.Tr("auth.active_your_account") c.Success(user2.ACTIVATE) } else { diff --git a/internal/route/install.go b/internal/route/install.go index 16054e83..c9d13d98 100644 --- a/internal/route/install.go +++ b/internal/route/install.go @@ -180,16 +180,16 @@ func Install(c *context.Context) { f.SMTPFrom = conf.Email.From f.SMTPUser = conf.Email.User } - f.RegisterConfirm = conf.Service.RegisterEmailConfirm - f.MailNotify = conf.Service.EnableNotifyMail + f.RegisterConfirm = conf.Auth.RequireEmailConfirmation + f.MailNotify = conf.User.EnableEmailNotification // Server and other services settings f.OfflineMode = conf.Server.OfflineMode f.DisableGravatar = conf.DisableGravatar f.EnableFederatedAvatar = conf.EnableFederatedAvatar - f.DisableRegistration = conf.Service.DisableRegistration - f.EnableCaptcha = conf.Service.EnableCaptcha - f.RequireSignInView = conf.Service.RequireSignInView + f.DisableRegistration = conf.Auth.DisableRegistration + f.EnableCaptcha = conf.Auth.EnableRegistrationCaptcha + f.RequireSignInView = conf.Auth.RequireSigninView form.Assign(f, c.Data) c.Success(INSTALL) diff --git a/internal/route/repo/http.go b/internal/route/repo/http.go index 07c89326..59aea393 100644 --- a/internal/route/repo/http.go +++ b/internal/route/repo/http.go @@ -77,7 +77,7 @@ func HTTPContexter() macaron.Handler { } // Authentication is not required for pulling from public repositories. - if isPull && !repo.IsPrivate && !conf.Service.RequireSignInView { + if isPull && !repo.IsPrivate && !conf.Auth.RequireSigninView { c.Map(&HTTPContext{ Context: c, }) diff --git a/internal/route/repo/setting.go b/internal/route/repo/setting.go index e1049cca..405ead4f 100644 --- a/internal/route/repo/setting.go +++ b/internal/route/repo/setting.go @@ -18,8 +18,8 @@ import ( "gogs.io/gogs/internal/context" "gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db/errors" - "gogs.io/gogs/internal/form" "gogs.io/gogs/internal/email" + "gogs.io/gogs/internal/form" "gogs.io/gogs/internal/tool" ) @@ -398,7 +398,7 @@ func SettingsCollaborationPost(c *context.Context) { return } - if conf.Service.EnableNotifyMail { + if conf.User.EnableEmailNotification { email.SendCollaboratorMail(db.NewMailerUser(u), db.NewMailerUser(c.User), db.NewMailerRepo(c.Repo.Repository)) } diff --git a/internal/route/user/auth.go b/internal/route/user/auth.go index 5a7bd8e4..7c29634b 100644 --- a/internal/route/user/auth.go +++ b/internal/route/user/auth.go @@ -292,9 +292,9 @@ func SignOut(c *context.Context) { func SignUp(c *context.Context) { c.Title("sign_up") - c.Data["EnableCaptcha"] = conf.Service.EnableCaptcha + c.Data["EnableCaptcha"] = conf.Auth.EnableRegistrationCaptcha - if conf.Service.DisableRegistration { + if conf.Auth.DisableRegistration { c.Data["DisableRegistration"] = true c.Success(SIGNUP) return @@ -306,9 +306,9 @@ func SignUp(c *context.Context) { func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) { c.Title("sign_up") - c.Data["EnableCaptcha"] = conf.Service.EnableCaptcha + c.Data["EnableCaptcha"] = conf.Auth.EnableRegistrationCaptcha - if conf.Service.DisableRegistration { + if conf.Auth.DisableRegistration { c.Status(403) return } @@ -318,7 +318,7 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) { return } - if conf.Service.EnableCaptcha && !cpt.VerifyReq(c.Req) { + if conf.Auth.EnableRegistrationCaptcha && !cpt.VerifyReq(c.Req) { c.FormErr("Captcha") c.RenderWithErr(c.Tr("form.captcha_incorrect"), SIGNUP, &f) return @@ -334,7 +334,7 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) { Name: f.UserName, Email: f.Email, Passwd: f.Password, - IsActive: !conf.Service.RegisterEmailConfirm, + IsActive: !conf.Auth.RequireEmailConfirmation, } if err := db.CreateUser(u); err != nil { switch { @@ -368,11 +368,11 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) { } // Send confirmation email, no need for social account. - if conf.Service.RegisterEmailConfirm && u.ID > 1 { + if conf.Auth.RegisterEmailConfirm && u.ID > 1 { email.SendActivateAccountMail(c.Context, db.NewMailerUser(u)) c.Data["IsSendRegisterMail"] = true c.Data["Email"] = u.Email - c.Data["Hours"] = conf.Service.ActiveCodeLives / 60 + c.Data["Hours"] = conf.Auth.ActivateCodeLives / 60 c.Success(ACTIVATE) if err := c.Cache.Put(u.MailResendCacheKey(), 1, 180); err != nil { @@ -393,11 +393,11 @@ func Activate(c *context.Context) { return } // Resend confirmation email. - if conf.Service.RegisterEmailConfirm { + if conf.Auth.RequireEmailConfirmation { if c.Cache.IsExist(c.User.MailResendCacheKey()) { c.Data["ResendLimited"] = true } else { - c.Data["Hours"] = conf.Service.ActiveCodeLives / 60 + c.Data["Hours"] = conf.Auth.ActivateCodeLives / 60 email.SendActivateAccountMail(c.Context, db.NewMailerUser(c.User)) if err := c.Cache.Put(c.User.MailResendCacheKey(), 1, 180); err != nil { @@ -482,7 +482,7 @@ func ForgotPasswdPost(c *context.Context) { u, err := db.GetUserByEmail(emailAddr) if err != nil { if errors.IsUserNotExist(err) { - c.Data["Hours"] = conf.Service.ActiveCodeLives / 60 + c.Data["Hours"] = conf.Auth.ActivateCodeLives / 60 c.Data["IsResetSent"] = true c.Success(FORGOT_PASSWORD) return @@ -509,7 +509,7 @@ func ForgotPasswdPost(c *context.Context) { log.Error("Failed to put cache key 'mail resend': %v", err) } - c.Data["Hours"] = conf.Service.ActiveCodeLives / 60 + c.Data["Hours"] = conf.Auth.ActivateCodeLives / 60 c.Data["IsResetSent"] = true c.Success(FORGOT_PASSWORD) } diff --git a/internal/route/user/setting.go b/internal/route/user/setting.go index 064ebf74..c61309c2 100644 --- a/internal/route/user/setting.go +++ b/internal/route/user/setting.go @@ -262,7 +262,7 @@ func SettingsEmailPost(c *context.Context, f form.AddEmail) { emailAddr := &db.EmailAddress{ UID: c.User.ID, Email: f.Email, - IsActivated: !conf.Service.RegisterEmailConfirm, + IsActivated: !conf.Auth.RequireEmailConfirmation, } if err := db.AddEmailAddress(emailAddr); err != nil { if db.IsErrEmailAlreadyUsed(err) { @@ -274,13 +274,13 @@ func SettingsEmailPost(c *context.Context, f form.AddEmail) { } // Send confirmation email - if conf.Service.RegisterEmailConfirm { + if conf.Auth.RequireEmailConfirmation { email.SendActivateEmailMail(c.Context, db.NewMailerUser(c.User), emailAddr.Email) if err := c.Cache.Put("MailResendLimit_"+c.User.LowerName, c.User.LowerName, 180); err != nil { log.Error("Set cache 'MailResendLimit' failed: %v", err) } - c.Flash.Info(c.Tr("settings.add_email_confirmation_sent", emailAddr.Email, conf.Service.ActiveCodeLives/60)) + c.Flash.Info(c.Tr("settings.add_email_confirmation_sent", emailAddr.Email, conf.Auth.ActivateCodeLives/60)) } else { c.Flash.Success(c.Tr("settings.add_email_success")) } |