|
|
@@ -76,6 +76,7 @@ const (
|
|
|
NotificationTPL = "user/notification"
|
|
|
)
|
|
|
|
|
|
+// Settings shows settings page
|
|
|
func Settings(c *context.Context) {
|
|
|
c.Title("settings.profile")
|
|
|
c.PageIs("SettingsProfile")
|
|
|
@@ -97,6 +98,7 @@ func Settings(c *context.Context) {
|
|
|
c.Success(SettingsProfileTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsPost updates user settings
|
|
|
func SettingsPost(c *context.Context, f form.UpdateProfile) {
|
|
|
c.Title("settings.profile")
|
|
|
c.PageIs("SettingsProfile")
|
|
|
@@ -172,6 +174,7 @@ func SettingsPost(c *context.Context, f form.UpdateProfile) {
|
|
|
c.SubURLRedirect("/user/settings")
|
|
|
}
|
|
|
|
|
|
+// SettingsSocial shows user social settings page
|
|
|
func SettingsSocial(c *context.Context) {
|
|
|
c.Title("settings.social")
|
|
|
c.PageIs("SettingsSocial")
|
|
|
@@ -188,6 +191,7 @@ func SettingsSocial(c *context.Context) {
|
|
|
c.Success(SettingsSocialTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsSocialPost updates user social settings
|
|
|
func SettingsSocialPost(c *context.Context, f form.UpdateSocial) {
|
|
|
c.Title("settings.profile")
|
|
|
c.PageIs("SettingsProfile")
|
|
|
@@ -216,7 +220,7 @@ func SettingsSocialPost(c *context.Context, f form.UpdateSocial) {
|
|
|
c.SubURLRedirect("/user/settings/social")
|
|
|
}
|
|
|
|
|
|
-// FIXME: limit upload size
|
|
|
+// UpdateAvatarSetting FIXME: limit upload size
|
|
|
func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxUser *models.User) error {
|
|
|
ctxUser.UseCustomAvatar = f.Source == form.AVATAR_LOCAL
|
|
|
if len(f.Gravatar) > 0 {
|
|
|
@@ -259,12 +263,14 @@ func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxUser *models.User
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+// SettingsAvatar shows user avatar settings page
|
|
|
func SettingsAvatar(c *context.Context) {
|
|
|
c.Title("settings.avatar")
|
|
|
c.PageIs("SettingsAvatar")
|
|
|
c.Success(SettingsAvatarTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsAvatarPost updates user avatar settings
|
|
|
func SettingsAvatarPost(c *context.Context, f form.Avatar) {
|
|
|
if err := UpdateAvatarSetting(c, f, c.User); err != nil {
|
|
|
c.Flash.Error(err.Error())
|
|
|
@@ -275,6 +281,7 @@ func SettingsAvatarPost(c *context.Context, f form.Avatar) {
|
|
|
c.SubURLRedirect("/user/settings/avatar")
|
|
|
}
|
|
|
|
|
|
+// SettingsDeleteAvatar shows user delete avatar settings page
|
|
|
func SettingsDeleteAvatar(c *context.Context) {
|
|
|
if err := c.User.DeleteAvatar(); err != nil {
|
|
|
c.Flash.Error(fmt.Sprintf("Failed to delete avatar: %v", err))
|
|
|
@@ -283,12 +290,14 @@ func SettingsDeleteAvatar(c *context.Context) {
|
|
|
c.SubURLRedirect("/user/settings/avatar")
|
|
|
}
|
|
|
|
|
|
+// SettingsPassword shows user password settings page
|
|
|
func SettingsPassword(c *context.Context) {
|
|
|
c.Title("settings.password")
|
|
|
c.PageIs("SettingsPassword")
|
|
|
c.Success(SettingsPasswordTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsPasswordPost updates user password settings
|
|
|
func SettingsPasswordPost(c *context.Context, f form.ChangePassword) {
|
|
|
c.Title("settings.password")
|
|
|
c.PageIs("SettingsPassword")
|
|
|
@@ -320,6 +329,7 @@ func SettingsPasswordPost(c *context.Context, f form.ChangePassword) {
|
|
|
c.SubURLRedirect("/user/settings/password")
|
|
|
}
|
|
|
|
|
|
+// SettingsEmails shows user email settings page
|
|
|
func SettingsEmails(c *context.Context) {
|
|
|
c.Title("settings.emails")
|
|
|
c.PageIs("SettingsEmails")
|
|
|
@@ -334,6 +344,7 @@ func SettingsEmails(c *context.Context) {
|
|
|
c.Success(SettingsEmailsTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsEmailPost updates user email settings
|
|
|
func SettingsEmailPost(c *context.Context, f form.AddEmail) {
|
|
|
c.Title("settings.emails")
|
|
|
c.PageIs("SettingsEmails")
|
|
|
@@ -392,6 +403,7 @@ func SettingsEmailPost(c *context.Context, f form.AddEmail) {
|
|
|
c.SubURLRedirect("/user/settings/email")
|
|
|
}
|
|
|
|
|
|
+// DeleteEmail shows user delete email settings page
|
|
|
func DeleteEmail(c *context.Context) {
|
|
|
if err := models.DeleteEmailAddress(&models.EmailAddress{
|
|
|
ID: c.QueryInt64("id"),
|
|
|
@@ -407,6 +419,7 @@ func DeleteEmail(c *context.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// SettingsSSHKeys shows user SSH settings page
|
|
|
func SettingsSSHKeys(c *context.Context) {
|
|
|
c.Title("settings.ssh_keys")
|
|
|
c.PageIs("SettingsSSHKeys")
|
|
|
@@ -421,6 +434,7 @@ func SettingsSSHKeys(c *context.Context) {
|
|
|
c.Success(SettingsSSHKeysTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsSSHKeysPost updates user SSH settings
|
|
|
func SettingsSSHKeysPost(c *context.Context, f form.AddSSHKey) {
|
|
|
c.Title("settings.ssh_keys")
|
|
|
c.PageIs("SettingsSSHKeys")
|
|
|
@@ -467,6 +481,7 @@ func SettingsSSHKeysPost(c *context.Context, f form.AddSSHKey) {
|
|
|
c.SubURLRedirect("/user/settings/ssh")
|
|
|
}
|
|
|
|
|
|
+// DeleteSSHKey shows user SSH delete settings page
|
|
|
func DeleteSSHKey(c *context.Context) {
|
|
|
if err := models.DeletePublicKey(c.User, c.QueryInt64("id")); err != nil {
|
|
|
c.Flash.Error("DeletePublicKey: " + err.Error())
|
|
|
@@ -479,6 +494,7 @@ func DeleteSSHKey(c *context.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// SettingsSecurity shows user security settings page
|
|
|
func SettingsSecurity(c *context.Context) {
|
|
|
c.Title("settings.security")
|
|
|
c.PageIs("SettingsSecurity")
|
|
|
@@ -493,6 +509,7 @@ func SettingsSecurity(c *context.Context) {
|
|
|
c.Success(SettingsSecurityTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsTwoFactorEnable shows user 2FA settings page
|
|
|
func SettingsTwoFactorEnable(c *context.Context) {
|
|
|
if c.User.IsEnabledTwoFactor() {
|
|
|
c.NotFound()
|
|
|
@@ -538,6 +555,7 @@ func SettingsTwoFactorEnable(c *context.Context) {
|
|
|
c.Success(SettingsTwoFactorEnableTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsTwoFactorEnablePost updates user 2FA settings
|
|
|
func SettingsTwoFactorEnablePost(c *context.Context) {
|
|
|
secret, ok := c.Session.Get("twoFactorSecret").(string)
|
|
|
if !ok {
|
|
|
@@ -563,6 +581,7 @@ func SettingsTwoFactorEnablePost(c *context.Context) {
|
|
|
c.SubURLRedirect("/user/settings/security/two_factor_recovery_codes")
|
|
|
}
|
|
|
|
|
|
+// SettingsTwoFactorRecoveryCodes shows user 2FA recovery settings page
|
|
|
func SettingsTwoFactorRecoveryCodes(c *context.Context) {
|
|
|
if !c.User.IsEnabledTwoFactor() {
|
|
|
c.NotFound()
|
|
|
@@ -582,6 +601,7 @@ func SettingsTwoFactorRecoveryCodes(c *context.Context) {
|
|
|
c.Success(SettingsTwoFactorRecoveryCodesTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsTwoFactorRecoveryCodesPost updates user 2FA recovery settings
|
|
|
func SettingsTwoFactorRecoveryCodesPost(c *context.Context) {
|
|
|
if !c.User.IsEnabledTwoFactor() {
|
|
|
c.NotFound()
|
|
|
@@ -597,6 +617,7 @@ func SettingsTwoFactorRecoveryCodesPost(c *context.Context) {
|
|
|
c.SubURLRedirect("/user/settings/security/two_factor_recovery_codes")
|
|
|
}
|
|
|
|
|
|
+// SettingsTwoFactorDisable shows user disable 2FA settings page
|
|
|
func SettingsTwoFactorDisable(c *context.Context) {
|
|
|
if !c.User.IsEnabledTwoFactor() {
|
|
|
c.NotFound()
|
|
|
@@ -614,6 +635,7 @@ func SettingsTwoFactorDisable(c *context.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// SettingsRepos shows user repo settings page
|
|
|
func SettingsRepos(c *context.Context) {
|
|
|
c.Title("settings.repos")
|
|
|
c.PageIs("SettingsRepositories")
|
|
|
@@ -632,6 +654,7 @@ func SettingsRepos(c *context.Context) {
|
|
|
c.Success(SettingsRepositoriesTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsLeaveRepo shows user leave repo settings page
|
|
|
func SettingsLeaveRepo(c *context.Context) {
|
|
|
repo, err := models.GetRepositoryByID(c.QueryInt64("id"))
|
|
|
if err != nil {
|
|
|
@@ -650,6 +673,7 @@ func SettingsLeaveRepo(c *context.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// SettingsOrganizations shows org settings page
|
|
|
func SettingsOrganizations(c *context.Context) {
|
|
|
c.Title("settings.orgs")
|
|
|
c.PageIs("SettingsOrganizations")
|
|
|
@@ -664,6 +688,7 @@ func SettingsOrganizations(c *context.Context) {
|
|
|
c.Success(SettingsOrganizationsTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsLeaveOrganization shows user leave org settings page
|
|
|
func SettingsLeaveOrganization(c *context.Context) {
|
|
|
if err := models.RemoveOrgUser(c.QueryInt64("id"), c.User.ID); err != nil {
|
|
|
if models.IsErrLastOrgOwner(err) {
|
|
|
@@ -679,6 +704,7 @@ func SettingsLeaveOrganization(c *context.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// SettingsApplications shows application settings page
|
|
|
func SettingsApplications(c *context.Context) {
|
|
|
c.Title("settings.applications")
|
|
|
c.PageIs("SettingsApplications")
|
|
|
@@ -693,6 +719,7 @@ func SettingsApplications(c *context.Context) {
|
|
|
c.Success(SettingsApplicationsTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsApplicationsPost updates application settings
|
|
|
func SettingsApplicationsPost(c *context.Context, f form.NewAccessToken) {
|
|
|
c.Title("settings.applications")
|
|
|
c.PageIs("SettingsApplications")
|
|
|
@@ -723,6 +750,7 @@ func SettingsApplicationsPost(c *context.Context, f form.NewAccessToken) {
|
|
|
c.SubURLRedirect("/user/settings/applications")
|
|
|
}
|
|
|
|
|
|
+// SettingsDeleteApplication shows delete application settings page
|
|
|
func SettingsDeleteApplication(c *context.Context) {
|
|
|
if err := models.DeleteAccessTokenOfUserByID(c.User.ID, c.QueryInt64("id")); err != nil {
|
|
|
c.Flash.Error("DeleteAccessTokenByID: " + err.Error())
|
|
|
@@ -735,6 +763,7 @@ func SettingsDeleteApplication(c *context.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// SettingsEmbeds shows user embed settings page
|
|
|
func SettingsEmbeds(c *context.Context) {
|
|
|
c.Title("settings.embeds")
|
|
|
c.PageIs("SettingsEmbeds")
|
|
|
@@ -742,6 +771,7 @@ func SettingsEmbeds(c *context.Context) {
|
|
|
c.Success(SettingsEmbedsTPL)
|
|
|
}
|
|
|
|
|
|
+// SettingsDelete shows user delete settings page
|
|
|
func SettingsDelete(c *context.Context) {
|
|
|
c.Title("settings.delete")
|
|
|
c.PageIs("SettingsDelete")
|