|
|
@@ -30,21 +30,50 @@ import (
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
- SETTINGS_PROFILE = "user/settings/profile"
|
|
|
- SETTINGS_SOCIAL = "user/settings/social"
|
|
|
- SETTINGS_AVATAR = "user/settings/avatar"
|
|
|
- SETTINGS_PASSWORD = "user/settings/password"
|
|
|
- SETTINGS_EMAILS = "user/settings/email"
|
|
|
- SETTINGS_SSH_KEYS = "user/settings/sshkeys"
|
|
|
- SETTINGS_SECURITY = "user/settings/security"
|
|
|
- SETTINGS_TWO_FACTOR_ENABLE = "user/settings/two_factor_enable"
|
|
|
- SETTINGS_TWO_FACTOR_RECOVERY_CODES = "user/settings/two_factor_recovery_codes"
|
|
|
- SETTINGS_REPOSITORIES = "user/settings/repositories"
|
|
|
- SETTINGS_ORGANIZATIONS = "user/settings/organizations"
|
|
|
- SETTINGS_APPLICATIONS = "user/settings/applications"
|
|
|
- SETTINGS_EMBEDS = "user/settings/embeds"
|
|
|
- SETTINGS_DELETE = "user/settings/delete"
|
|
|
- NOTIFICATION = "user/notification"
|
|
|
+ // SettingsProfileTPL page template
|
|
|
+ SettingsProfileTPL = "user/settings/profile"
|
|
|
+
|
|
|
+ // SettingsSocialTPL page template
|
|
|
+ SettingsSocialTPL = "user/settings/social"
|
|
|
+
|
|
|
+ // SettingsAvatarTPL page template
|
|
|
+ SettingsAvatarTPL = "user/settings/avatar"
|
|
|
+
|
|
|
+ // SettingsPasswordTPL page template
|
|
|
+ SettingsPasswordTPL = "user/settings/password"
|
|
|
+
|
|
|
+ // SettingsEmailsTPL page template
|
|
|
+ SettingsEmailsTPL = "user/settings/email"
|
|
|
+
|
|
|
+ // SettingsSSHKeysTPL page template
|
|
|
+ SettingsSSHKeysTPL = "user/settings/sshkeys"
|
|
|
+
|
|
|
+ // SettingsSecurityTPL page template
|
|
|
+ SettingsSecurityTPL = "user/settings/security"
|
|
|
+
|
|
|
+ // SettingsTwoFactorEnableTPL page template
|
|
|
+ SettingsTwoFactorEnableTPL = "user/settings/two_factor_enable"
|
|
|
+
|
|
|
+ // SettingsTwoFactorRecoveryCodesTPL page template
|
|
|
+ SettingsTwoFactorRecoveryCodesTPL = "user/settings/two_factor_recovery_codes"
|
|
|
+
|
|
|
+ // SettingsRepositoriesTPL page template
|
|
|
+ SettingsRepositoriesTPL = "user/settings/repositories"
|
|
|
+
|
|
|
+ // SettingsOrganizationsTPL page template
|
|
|
+ SettingsOrganizationsTPL = "user/settings/organizations"
|
|
|
+
|
|
|
+ // SettingsApplicationsTPL page template
|
|
|
+ SettingsApplicationsTPL = "user/settings/applications"
|
|
|
+
|
|
|
+ // SettingsEmbedsTPL page template
|
|
|
+ SettingsEmbedsTPL = "user/settings/embeds"
|
|
|
+
|
|
|
+ // SettingsDeleteTPL page template
|
|
|
+ SettingsDeleteTPL = "user/settings/delete"
|
|
|
+
|
|
|
+ // NotificationTPL page template
|
|
|
+ NotificationTPL = "user/notification"
|
|
|
)
|
|
|
|
|
|
func Settings(c *context.Context) {
|
|
|
@@ -65,7 +94,7 @@ func Settings(c *context.Context) {
|
|
|
c.Data["show_ads"] = c.User.ShowAds
|
|
|
c.Data["private_email"] = c.User.PrivateEmail
|
|
|
c.Data["private_profile"] = c.User.PrivateProfile
|
|
|
- c.Success(SETTINGS_PROFILE)
|
|
|
+ c.Success(SettingsProfileTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsPost(c *context.Context, f form.UpdateProfile) {
|
|
|
@@ -74,7 +103,7 @@ func SettingsPost(c *context.Context, f form.UpdateProfile) {
|
|
|
c.Data["origin_name"] = c.User.Name
|
|
|
|
|
|
if c.HasError() {
|
|
|
- c.Success(SETTINGS_PROFILE)
|
|
|
+ c.Success(SettingsProfileTPL)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -97,7 +126,7 @@ func SettingsPost(c *context.Context, f form.UpdateProfile) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- c.RenderWithErr(msg, SETTINGS_PROFILE, &f)
|
|
|
+ c.RenderWithErr(msg, SettingsProfileTPL, &f)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -113,7 +142,7 @@ func SettingsPost(c *context.Context, f form.UpdateProfile) {
|
|
|
if c.User.Email != email {
|
|
|
if used, err := models.IsEmailUsed(email); used {
|
|
|
c.FormErr("Email")
|
|
|
- c.RenderWithErr(c.Tr("form.email_been_used"), SETTINGS_PROFILE, &f)
|
|
|
+ c.RenderWithErr(c.Tr("form.email_been_used"), SettingsProfileTPL, &f)
|
|
|
return
|
|
|
} else if err != nil {
|
|
|
c.ServerError("ChangeUserName", err)
|
|
|
@@ -156,7 +185,7 @@ func SettingsSocial(c *context.Context) {
|
|
|
c.Data["telegram"] = c.User.Telegram
|
|
|
c.Data["codepen"] = c.User.Codepen
|
|
|
c.Data["gitlab"] = c.User.Gitlab
|
|
|
- c.Success(SETTINGS_SOCIAL)
|
|
|
+ c.Success(SettingsSocialTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsSocialPost(c *context.Context, f form.UpdateSocial) {
|
|
|
@@ -165,7 +194,7 @@ func SettingsSocialPost(c *context.Context, f form.UpdateSocial) {
|
|
|
c.Data["origin_name"] = c.User.Name
|
|
|
|
|
|
if c.HasError() {
|
|
|
- c.Success(SETTINGS_SOCIAL)
|
|
|
+ c.Success(SettingsSocialTPL)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -233,7 +262,7 @@ func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxUser *models.User
|
|
|
func SettingsAvatar(c *context.Context) {
|
|
|
c.Title("settings.avatar")
|
|
|
c.PageIs("SettingsAvatar")
|
|
|
- c.Success(SETTINGS_AVATAR)
|
|
|
+ c.Success(SettingsAvatarTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsAvatarPost(c *context.Context, f form.Avatar) {
|
|
|
@@ -257,7 +286,7 @@ func SettingsDeleteAvatar(c *context.Context) {
|
|
|
func SettingsPassword(c *context.Context) {
|
|
|
c.Title("settings.password")
|
|
|
c.PageIs("SettingsPassword")
|
|
|
- c.Success(SETTINGS_PASSWORD)
|
|
|
+ c.Success(SettingsPasswordTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsPasswordPost(c *context.Context, f form.ChangePassword) {
|
|
|
@@ -265,7 +294,7 @@ func SettingsPasswordPost(c *context.Context, f form.ChangePassword) {
|
|
|
c.PageIs("SettingsPassword")
|
|
|
|
|
|
if c.HasError() {
|
|
|
- c.Success(SETTINGS_PASSWORD)
|
|
|
+ c.Success(SettingsPasswordTPL)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -302,7 +331,7 @@ func SettingsEmails(c *context.Context) {
|
|
|
}
|
|
|
c.Data["Emails"] = emails
|
|
|
|
|
|
- c.Success(SETTINGS_EMAILS)
|
|
|
+ c.Success(SettingsEmailsTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsEmailPost(c *context.Context, f form.AddEmail) {
|
|
|
@@ -329,7 +358,7 @@ func SettingsEmailPost(c *context.Context, f form.AddEmail) {
|
|
|
c.Data["Emails"] = emails
|
|
|
|
|
|
if c.HasError() {
|
|
|
- c.Success(SETTINGS_EMAILS)
|
|
|
+ c.Success(SettingsEmailsTPL)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -340,7 +369,7 @@ func SettingsEmailPost(c *context.Context, f form.AddEmail) {
|
|
|
}
|
|
|
if err := models.AddEmailAddress(email); err != nil {
|
|
|
if models.IsErrEmailAlreadyUsed(err) {
|
|
|
- c.RenderWithErr(c.Tr("form.email_been_used"), SETTINGS_EMAILS, &f)
|
|
|
+ c.RenderWithErr(c.Tr("form.email_been_used"), SettingsEmailsTPL, &f)
|
|
|
} else {
|
|
|
c.ServerError("AddEmailAddress", err)
|
|
|
}
|
|
|
@@ -389,7 +418,7 @@ func SettingsSSHKeys(c *context.Context) {
|
|
|
}
|
|
|
c.Data["Keys"] = keys
|
|
|
|
|
|
- c.Success(SETTINGS_SSH_KEYS)
|
|
|
+ c.Success(SettingsSSHKeysTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsSSHKeysPost(c *context.Context, f form.AddSSHKey) {
|
|
|
@@ -404,7 +433,7 @@ func SettingsSSHKeysPost(c *context.Context, f form.AddSSHKey) {
|
|
|
c.Data["Keys"] = keys
|
|
|
|
|
|
if c.HasError() {
|
|
|
- c.Success(SETTINGS_SSH_KEYS)
|
|
|
+ c.Success(SettingsSSHKeysTPL)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -424,10 +453,10 @@ func SettingsSSHKeysPost(c *context.Context, f form.AddSSHKey) {
|
|
|
switch {
|
|
|
case models.IsErrKeyAlreadyExist(err):
|
|
|
c.FormErr("Content")
|
|
|
- c.RenderWithErr(c.Tr("settings.ssh_key_been_used"), SETTINGS_SSH_KEYS, &f)
|
|
|
+ c.RenderWithErr(c.Tr("settings.ssh_key_been_used"), SettingsSSHKeysTPL, &f)
|
|
|
case models.IsErrKeyNameAlreadyUsed(err):
|
|
|
c.FormErr("Title")
|
|
|
- c.RenderWithErr(c.Tr("settings.ssh_key_name_used"), SETTINGS_SSH_KEYS, &f)
|
|
|
+ c.RenderWithErr(c.Tr("settings.ssh_key_name_used"), SettingsSSHKeysTPL, &f)
|
|
|
default:
|
|
|
c.ServerError("AddPublicKey", err)
|
|
|
}
|
|
|
@@ -461,7 +490,7 @@ func SettingsSecurity(c *context.Context) {
|
|
|
}
|
|
|
c.Data["TwoFactor"] = t
|
|
|
|
|
|
- c.Success(SETTINGS_SECURITY)
|
|
|
+ c.Success(SettingsSecurityTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsTwoFactorEnable(c *context.Context) {
|
|
|
@@ -506,7 +535,7 @@ func SettingsTwoFactorEnable(c *context.Context) {
|
|
|
|
|
|
c.Session.Set("twoFactorSecret", c.Data["TwoFactorSecret"])
|
|
|
c.Session.Set("twoFactorURL", key.String())
|
|
|
- c.Success(SETTINGS_TWO_FACTOR_ENABLE)
|
|
|
+ c.Success(SettingsTwoFactorEnableTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsTwoFactorEnablePost(c *context.Context) {
|
|
|
@@ -550,7 +579,7 @@ func SettingsTwoFactorRecoveryCodes(c *context.Context) {
|
|
|
}
|
|
|
c.Data["RecoveryCodes"] = recoveryCodes
|
|
|
|
|
|
- c.Success(SETTINGS_TWO_FACTOR_RECOVERY_CODES)
|
|
|
+ c.Success(SettingsTwoFactorRecoveryCodesTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsTwoFactorRecoveryCodesPost(c *context.Context) {
|
|
|
@@ -600,7 +629,7 @@ func SettingsRepos(c *context.Context) {
|
|
|
}
|
|
|
c.Data["Repos"] = repos
|
|
|
|
|
|
- c.Success(SETTINGS_REPOSITORIES)
|
|
|
+ c.Success(SettingsRepositoriesTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsLeaveRepo(c *context.Context) {
|
|
|
@@ -632,7 +661,7 @@ func SettingsOrganizations(c *context.Context) {
|
|
|
}
|
|
|
c.Data["Orgs"] = orgs
|
|
|
|
|
|
- c.Success(SETTINGS_ORGANIZATIONS)
|
|
|
+ c.Success(SettingsOrganizationsTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsLeaveOrganization(c *context.Context) {
|
|
|
@@ -661,7 +690,7 @@ func SettingsApplications(c *context.Context) {
|
|
|
}
|
|
|
c.Data["Tokens"] = tokens
|
|
|
|
|
|
- c.Success(SETTINGS_APPLICATIONS)
|
|
|
+ c.Success(SettingsApplicationsTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsApplicationsPost(c *context.Context, f form.NewAccessToken) {
|
|
|
@@ -676,7 +705,7 @@ func SettingsApplicationsPost(c *context.Context, f form.NewAccessToken) {
|
|
|
}
|
|
|
|
|
|
c.Data["Tokens"] = tokens
|
|
|
- c.Success(SETTINGS_APPLICATIONS)
|
|
|
+ c.Success(SettingsApplicationsTPL)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -710,7 +739,7 @@ func SettingsEmbeds(c *context.Context) {
|
|
|
c.Title("settings.embeds")
|
|
|
c.PageIs("SettingsEmbeds")
|
|
|
|
|
|
- c.Success(SETTINGS_EMBEDS)
|
|
|
+ c.Success(SettingsEmbedsTPL)
|
|
|
}
|
|
|
|
|
|
func SettingsDelete(c *context.Context) {
|
|
|
@@ -720,7 +749,7 @@ func SettingsDelete(c *context.Context) {
|
|
|
if c.Req.Method == "POST" {
|
|
|
if _, err := models.UserLogin(c.User.Name, c.Query("password"), c.User.LoginSource); err != nil {
|
|
|
if errors.IsUserNotExist(err) {
|
|
|
- c.RenderWithErr(c.Tr("form.enterred_invalid_password"), SETTINGS_DELETE, nil)
|
|
|
+ c.RenderWithErr(c.Tr("form.enterred_invalid_password"), SettingsDeleteTPL, nil)
|
|
|
} else {
|
|
|
c.ServerError("UserLogin", err)
|
|
|
}
|
|
|
@@ -745,5 +774,5 @@ func SettingsDelete(c *context.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- c.Success(SETTINGS_DELETE)
|
|
|
+ c.Success(SettingsDeleteTPL)
|
|
|
}
|