diff options
Diffstat (limited to 'routers/user')
-rw-r--r-- | routers/user/auth.go | 80 | ||||
-rw-r--r-- | routers/user/home.go | 18 | ||||
-rw-r--r-- | routers/user/profile.go | 16 | ||||
-rw-r--r-- | routers/user/setting.go | 70 |
4 files changed, 113 insertions, 71 deletions
diff --git a/routers/user/auth.go b/routers/user/auth.go index 69f1db47b3..ebee24365c 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -19,11 +19,14 @@ import ( ) const ( - SIGNIN base.TplName = "user/auth/signin" - SIGNUP base.TplName = "user/auth/signup" - ACTIVATE base.TplName = "user/auth/activate" - FORGOT_PASSWORD base.TplName = "user/auth/forgot_passwd" - RESET_PASSWORD base.TplName = "user/auth/reset_passwd" + // tplSignIn template for sign in page + tplSignIn base.TplName = "user/auth/signin" + // tplSignUp template path for sign up page + tplSignUp base.TplName = "user/auth/signup" + // TplActivate template path for activate user + TplActivate base.TplName = "user/auth/activate" + tplForgotPassword base.TplName = "user/auth/forgot_passwd" + tplResetPassword base.TplName = "user/auth/reset_passwd" ) // AutoSignIn reads cookie and try to auto-login. @@ -66,6 +69,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) { return true, nil } +// SignIn render sign in page func SignIn(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("sign_in") @@ -93,21 +97,22 @@ func SignIn(ctx *context.Context) { return } - ctx.HTML(200, SIGNIN) + ctx.HTML(200, tplSignIn) } +// SignInPost response for sign in request func SignInPost(ctx *context.Context, form auth.SignInForm) { ctx.Data["Title"] = ctx.Tr("sign_in") if ctx.HasError() { - ctx.HTML(200, SIGNIN) + ctx.HTML(200, tplSignIn) return } u, err := models.UserSignIn(form.UserName, form.Password) if err != nil { if models.IsErrUserNotExist(err) { - ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), SIGNIN, &form) + ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), tplSignIn, &form) } else { ctx.Handle(500, "UserSignIn", err) } @@ -143,6 +148,7 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) { ctx.Redirect(setting.AppSubUrl + "/") } +// SignOut sign out from login status func SignOut(ctx *context.Context) { ctx.Session.Delete("uid") ctx.Session.Delete("uname") @@ -155,6 +161,7 @@ func SignOut(ctx *context.Context) { ctx.Redirect(setting.AppSubUrl + "/") } +// SignUp render the register page func SignUp(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("sign_up") @@ -162,13 +169,14 @@ func SignUp(ctx *context.Context) { if setting.Service.DisableRegistration { ctx.Data["DisableRegistration"] = true - ctx.HTML(200, SIGNUP) + ctx.HTML(200, tplSignUp) return } - ctx.HTML(200, SIGNUP) + ctx.HTML(200, tplSignUp) } +// SignUpPost response for sign up information submission func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterForm) { ctx.Data["Title"] = ctx.Tr("sign_up") @@ -180,19 +188,19 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo } if ctx.HasError() { - ctx.HTML(200, SIGNUP) + ctx.HTML(200, tplSignUp) return } if setting.Service.EnableCaptcha && !cpt.VerifyReq(ctx.Req) { ctx.Data["Err_Captcha"] = true - ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), SIGNUP, &form) + ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplSignUp, &form) return } if form.Password != form.Retype { ctx.Data["Err_Password"] = true - ctx.RenderWithErr(ctx.Tr("form.password_not_match"), SIGNUP, &form) + ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplSignUp, &form) return } @@ -206,16 +214,16 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo switch { case models.IsErrUserAlreadyExist(err): ctx.Data["Err_UserName"] = true - ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), SIGNUP, &form) + ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tplSignUp, &form) case models.IsErrEmailAlreadyUsed(err): ctx.Data["Err_Email"] = true - ctx.RenderWithErr(ctx.Tr("form.email_been_used"), SIGNUP, &form) + ctx.RenderWithErr(ctx.Tr("form.email_been_used"), tplSignUp, &form) case models.IsErrNameReserved(err): ctx.Data["Err_UserName"] = true - ctx.RenderWithErr(ctx.Tr("user.form.name_reserved", err.(models.ErrNameReserved).Name), SIGNUP, &form) + ctx.RenderWithErr(ctx.Tr("user.form.name_reserved", err.(models.ErrNameReserved).Name), tplSignUp, &form) case models.IsErrNamePatternNotAllowed(err): ctx.Data["Err_UserName"] = true - ctx.RenderWithErr(ctx.Tr("user.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), SIGNUP, &form) + ctx.RenderWithErr(ctx.Tr("user.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), tplSignUp, &form) default: ctx.Handle(500, "CreateUser", err) } @@ -239,7 +247,7 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo ctx.Data["IsSendRegisterMail"] = true ctx.Data["Email"] = u.Email ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 - ctx.HTML(200, ACTIVATE) + ctx.HTML(200, TplActivate) if err := ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil { log.Error(4, "Set cache(MailResendLimit) fail: %v", err) @@ -250,6 +258,7 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo ctx.Redirect(setting.AppSubUrl + "/user/login") } +// Activate render activate user page func Activate(ctx *context.Context) { code := ctx.Query("code") if len(code) == 0 { @@ -273,7 +282,7 @@ func Activate(ctx *context.Context) { } else { ctx.Data["ServiceNotEnabled"] = true } - ctx.HTML(200, ACTIVATE) + ctx.HTML(200, TplActivate) return } @@ -299,15 +308,16 @@ func Activate(ctx *context.Context) { } ctx.Data["IsActivateFailed"] = true - ctx.HTML(200, ACTIVATE) + ctx.HTML(200, TplActivate) } +// ActivateEmail render the activate email page func ActivateEmail(ctx *context.Context) { code := ctx.Query("code") - email_string := ctx.Query("email") + emailStr := ctx.Query("email") // Verify code. - if email := models.VerifyActiveEmailCode(code, email_string); email != nil { + if email := models.VerifyActiveEmailCode(code, emailStr); email != nil { if err := email.Activate(); err != nil { ctx.Handle(500, "ActivateEmail", err) } @@ -320,19 +330,21 @@ func ActivateEmail(ctx *context.Context) { return } +// ForgotPasswd render the forget pasword page func ForgotPasswd(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("auth.forgot_password") if setting.MailService == nil { ctx.Data["IsResetDisable"] = true - ctx.HTML(200, FORGOT_PASSWORD) + ctx.HTML(200, tplForgotPassword) return } ctx.Data["IsResetRequest"] = true - ctx.HTML(200, FORGOT_PASSWORD) + ctx.HTML(200, tplForgotPassword) } +// ForgotPasswdPost response for forget password request func ForgotPasswdPost(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("auth.forgot_password") @@ -350,23 +362,23 @@ func ForgotPasswdPost(ctx *context.Context) { if models.IsErrUserNotExist(err) { ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 ctx.Data["IsResetSent"] = true - ctx.HTML(200, FORGOT_PASSWORD) + ctx.HTML(200, tplForgotPassword) return - } else { - ctx.Handle(500, "user.ResetPasswd(check existence)", err) } + + ctx.Handle(500, "user.ResetPasswd(check existence)", err) return } if !u.IsLocal() { ctx.Data["Err_Email"] = true - ctx.RenderWithErr(ctx.Tr("auth.non_local_account"), FORGOT_PASSWORD, nil) + ctx.RenderWithErr(ctx.Tr("auth.non_local_account"), tplForgotPassword, nil) return } if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) { ctx.Data["ResendLimited"] = true - ctx.HTML(200, FORGOT_PASSWORD) + ctx.HTML(200, tplForgotPassword) return } @@ -377,9 +389,10 @@ func ForgotPasswdPost(ctx *context.Context) { ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 ctx.Data["IsResetSent"] = true - ctx.HTML(200, FORGOT_PASSWORD) + ctx.HTML(200, tplForgotPassword) } +// ResetPasswd render the reset password page func ResetPasswd(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("auth.reset_password") @@ -390,9 +403,10 @@ func ResetPasswd(ctx *context.Context) { } ctx.Data["Code"] = code ctx.Data["IsResetForm"] = true - ctx.HTML(200, RESET_PASSWORD) + ctx.HTML(200, tplResetPassword) } +// ResetPasswdPost response fro reset password request func ResetPasswdPost(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("auth.reset_password") @@ -409,7 +423,7 @@ func ResetPasswdPost(ctx *context.Context) { if len(passwd) < 6 { ctx.Data["IsResetForm"] = true ctx.Data["Err_Password"] = true - ctx.RenderWithErr(ctx.Tr("auth.password_too_short"), RESET_PASSWORD, nil) + ctx.RenderWithErr(ctx.Tr("auth.password_too_short"), tplResetPassword, nil) return } @@ -428,5 +442,5 @@ func ResetPasswdPost(ctx *context.Context) { } ctx.Data["IsResetFailed"] = true - ctx.HTML(200, RESET_PASSWORD) + ctx.HTML(200, tplResetPassword) } diff --git a/routers/user/home.go b/routers/user/home.go index b82daed291..e6b789e2f3 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -18,10 +18,10 @@ import ( ) const ( - DASHBOARD base.TplName = "user/dashboard/dashboard" - ISSUES base.TplName = "user/dashboard/issues" - PROFILE base.TplName = "user/profile" - ORG_HOME base.TplName = "org/home" + tplDashborad base.TplName = "user/dashboard/dashboard" + tplIssues base.TplName = "user/dashboard/issues" + tplProfile base.TplName = "user/profile" + tplOrgHome base.TplName = "org/home" ) // getDashboardContextUser finds out dashboard is viewing as which context user. @@ -86,6 +86,7 @@ func retrieveFeeds(ctx *context.Context, ctxUser *models.User, userID, offset in ctx.Data["Feeds"] = feeds } +// Dashboard render the dashborad page func Dashboard(ctx *context.Context) { ctxUser := getDashboardContextUser(ctx) if ctx.Written() { @@ -150,9 +151,10 @@ func Dashboard(ctx *context.Context) { if ctx.Written() { return } - ctx.HTML(200, DASHBOARD) + ctx.HTML(200, tplDashborad) } +// Issues render the user issues page func Issues(ctx *context.Context) { isPullList := ctx.Params(":type") == "pulls" if isPullList { @@ -308,9 +310,10 @@ func Issues(ctx *context.Context) { ctx.Data["State"] = "open" } - ctx.HTML(200, ISSUES) + ctx.HTML(200, tplIssues) } +// ShowSSHKeys ouput all the ssh keys of user by uid func ShowSSHKeys(ctx *context.Context, uid int64) { keys, err := models.ListPublicKeys(uid) if err != nil { @@ -373,9 +376,10 @@ func showOrgProfile(ctx *context.Context) { ctx.Data["Teams"] = org.Teams - ctx.HTML(200, ORG_HOME) + ctx.HTML(200, tplOrgHome) } +// Email2User show user page via email func Email2User(ctx *context.Context) { u, err := models.GetUserByEmail(ctx.Query("email")) if err != nil { diff --git a/routers/user/profile.go b/routers/user/profile.go index fc8ef442ba..a5f4a97efd 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -19,10 +19,11 @@ import ( ) const ( - FOLLOWERS base.TplName = "user/meta/followers" - STARS base.TplName = "user/meta/stars" + tplFollowers base.TplName = "user/meta/followers" + tplStars base.TplName = "user/meta/stars" ) +// GetUserByName get user by name func GetUserByName(ctx *context.Context, name string) *models.User { user, err := models.GetUserByName(name) if err != nil { @@ -41,6 +42,7 @@ func GetUserByParams(ctx *context.Context) *models.User { return GetUserByName(ctx, ctx.Params(":username")) } +// Profile render user's profile page func Profile(ctx *context.Context) { uname := ctx.Params(":username") // Special handle for FireFox requests favicon.ico. @@ -107,9 +109,10 @@ func Profile(ctx *context.Context) { ctx.Data["Page"] = paginater.New(ctxUser.NumRepos, setting.UI.User.RepoPagingNum, page, 5) } - ctx.HTML(200, PROFILE) + ctx.HTML(200, tplProfile) } +// Followers render user's followers page func Followers(ctx *context.Context) { u := GetUserByParams(ctx) if ctx.Written() { @@ -119,9 +122,10 @@ func Followers(ctx *context.Context) { ctx.Data["CardsTitle"] = ctx.Tr("user.followers") ctx.Data["PageIsFollowers"] = true ctx.Data["Owner"] = u - repo.RenderUserCards(ctx, u.NumFollowers, u.GetFollowers, FOLLOWERS) + repo.RenderUserCards(ctx, u.NumFollowers, u.GetFollowers, tplFollowers) } +// Following render user's followering page func Following(ctx *context.Context) { u := GetUserByParams(ctx) if ctx.Written() { @@ -131,13 +135,15 @@ func Following(ctx *context.Context) { ctx.Data["CardsTitle"] = ctx.Tr("user.following") ctx.Data["PageIsFollowing"] = true ctx.Data["Owner"] = u - repo.RenderUserCards(ctx, u.NumFollowing, u.GetFollowing, FOLLOWERS) + repo.RenderUserCards(ctx, u.NumFollowing, u.GetFollowing, tplFollowers) } +// Stars show repositories user starred func Stars(ctx *context.Context) { } +// Action response for follow/unfollow user request func Action(ctx *context.Context) { u := GetUserByParams(ctx) if ctx.Written() { diff --git a/routers/user/setting.go b/routers/user/setting.go index 8c4bc02a55..ae526162f3 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -21,22 +21,23 @@ import ( ) const ( - SETTINGS_PROFILE base.TplName = "user/settings/profile" - SETTINGS_AVATAR base.TplName = "user/settings/avatar" - SETTINGS_PASSWORD base.TplName = "user/settings/password" - SETTINGS_EMAILS base.TplName = "user/settings/email" - SETTINGS_SSH_KEYS base.TplName = "user/settings/sshkeys" - SETTINGS_SOCIAL base.TplName = "user/settings/social" - SETTINGS_APPLICATIONS base.TplName = "user/settings/applications" - SETTINGS_DELETE base.TplName = "user/settings/delete" - NOTIFICATION base.TplName = "user/notification" - SECURITY base.TplName = "user/security" + tplSettingsProfile base.TplName = "user/settings/profile" + tplSettingsAvatar base.TplName = "user/settings/avatar" + tplSettingsPassword base.TplName = "user/settings/password" + tplSettingsEmails base.TplName = "user/settings/email" + tplSettingsSSHKeys base.TplName = "user/settings/sshkeys" + tplSettingsSocial base.TplName = "user/settings/social" + tplSettingsApplications base.TplName = "user/settings/applications" + tplSettingsDelete base.TplName = "user/settings/delete" + tplNotification base.TplName = "user/notification" + tplSecurity base.TplName = "user/security" ) +// Settings render user's profile page func Settings(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsProfile"] = true - ctx.HTML(200, SETTINGS_PROFILE) + ctx.HTML(200, tplSettingsProfile) } func handleUsernameChange(ctx *context.Context, newName string) { @@ -74,12 +75,13 @@ func handleUsernameChange(ctx *context.Context, newName string) { ctx.User.LowerName = strings.ToLower(newName) } +// SettingsPost response for change user's profile func SettingsPost(ctx *context.Context, form auth.UpdateProfileForm) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsProfile"] = true if ctx.HasError() { - ctx.HTML(200, SETTINGS_PROFILE) + ctx.HTML(200, tplSettingsProfile) return } @@ -102,6 +104,7 @@ func SettingsPost(ctx *context.Context, form auth.UpdateProfileForm) { ctx.Redirect(setting.AppSubUrl + "/user/settings") } +// UpdateAvatarSetting update user's avatar // FIXME: limit size. func UpdateAvatarSetting(ctx *context.Context, form auth.AvatarForm, ctxUser *models.User) error { ctxUser.UseCustomAvatar = form.Source == auth.AvatarLocal @@ -144,12 +147,14 @@ func UpdateAvatarSetting(ctx *context.Context, form auth.AvatarForm, ctxUser *mo return nil } +// SettingsAvatar render user avatar page func SettingsAvatar(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsAvatar"] = true - ctx.HTML(200, SETTINGS_AVATAR) + ctx.HTML(200, tplSettingsAvatar) } +// SettingsAvatarPost response for change user's avatar request func SettingsAvatarPost(ctx *context.Context, form auth.AvatarForm) { if err := UpdateAvatarSetting(ctx, form, ctx.User); err != nil { ctx.Flash.Error(err.Error()) @@ -160,6 +165,7 @@ func SettingsAvatarPost(ctx *context.Context, form auth.AvatarForm) { ctx.Redirect(setting.AppSubUrl + "/user/settings/avatar") } +// SettingsDeleteAvatar render delete avatar page func SettingsDeleteAvatar(ctx *context.Context) { if err := ctx.User.DeleteAvatar(); err != nil { ctx.Flash.Error(err.Error()) @@ -168,18 +174,20 @@ func SettingsDeleteAvatar(ctx *context.Context) { ctx.Redirect(setting.AppSubUrl + "/user/settings/avatar") } +// SettingsPassword render change user's password page func SettingsPassword(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsPassword"] = true - ctx.HTML(200, SETTINGS_PASSWORD) + ctx.HTML(200, tplSettingsPassword) } +// SettingsPasswordPost response for change user's password func SettingsPasswordPost(ctx *context.Context, form auth.ChangePasswordForm) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsPassword"] = true if ctx.HasError() { - ctx.HTML(200, SETTINGS_PASSWORD) + ctx.HTML(200, tplSettingsPassword) return } @@ -202,6 +210,7 @@ func SettingsPasswordPost(ctx *context.Context, form auth.ChangePasswordForm) { ctx.Redirect(setting.AppSubUrl + "/user/settings/password") } +// SettingsEmails render user's emails page func SettingsEmails(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsEmails"] = true @@ -213,9 +222,10 @@ func SettingsEmails(ctx *context.Context) { } ctx.Data["Emails"] = emails - ctx.HTML(200, SETTINGS_EMAILS) + ctx.HTML(200, tplSettingsEmails) } +// SettingsEmailPost response for change user's email func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsEmails"] = true @@ -241,7 +251,7 @@ func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) { ctx.Data["Emails"] = emails if ctx.HasError() { - ctx.HTML(200, SETTINGS_EMAILS) + ctx.HTML(200, tplSettingsEmails) return } @@ -252,7 +262,7 @@ func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) { } if err := models.AddEmailAddress(email); err != nil { if models.IsErrEmailAlreadyUsed(err) { - ctx.RenderWithErr(ctx.Tr("form.email_been_used"), SETTINGS_EMAILS, &form) + ctx.RenderWithErr(ctx.Tr("form.email_been_used"), tplSettingsEmails, &form) return } ctx.Handle(500, "AddEmailAddress", err) @@ -275,6 +285,7 @@ func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) { ctx.Redirect(setting.AppSubUrl + "/user/settings/email") } +// DeleteEmail reponse for delete user's email func DeleteEmail(ctx *context.Context) { if err := models.DeleteEmailAddress(&models.EmailAddress{ID: ctx.QueryInt64("id")}); err != nil { ctx.Handle(500, "DeleteEmail", err) @@ -288,6 +299,7 @@ func DeleteEmail(ctx *context.Context) { }) } +// SettingsSSHKeys render user's SSH public keys page func SettingsSSHKeys(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsSSHKeys"] = true @@ -299,9 +311,10 @@ func SettingsSSHKeys(ctx *context.Context) { } ctx.Data["Keys"] = keys - ctx.HTML(200, SETTINGS_SSH_KEYS) + ctx.HTML(200, tplSettingsSSHKeys) } +// SettingsSSHKeysPost response for change user's SSH keys func SettingsSSHKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsSSHKeys"] = true @@ -314,7 +327,7 @@ func SettingsSSHKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) { ctx.Data["Keys"] = keys if ctx.HasError() { - ctx.HTML(200, SETTINGS_SSH_KEYS) + ctx.HTML(200, tplSettingsSSHKeys) return } @@ -334,10 +347,10 @@ func SettingsSSHKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) { switch { case models.IsErrKeyAlreadyExist(err): ctx.Data["Err_Content"] = true - ctx.RenderWithErr(ctx.Tr("settings.ssh_key_been_used"), SETTINGS_SSH_KEYS, &form) + ctx.RenderWithErr(ctx.Tr("settings.ssh_key_been_used"), tplSettingsSSHKeys, &form) case models.IsErrKeyNameAlreadyUsed(err): ctx.Data["Err_Title"] = true - ctx.RenderWithErr(ctx.Tr("settings.ssh_key_name_used"), SETTINGS_SSH_KEYS, &form) + ctx.RenderWithErr(ctx.Tr("settings.ssh_key_name_used"), tplSettingsSSHKeys, &form) default: ctx.Handle(500, "AddPublicKey", err) } @@ -348,6 +361,7 @@ func SettingsSSHKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) { ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh") } +// DeleteSSHKey response for delete user's SSH key func DeleteSSHKey(ctx *context.Context) { if err := models.DeletePublicKey(ctx.User, ctx.QueryInt64("id")); err != nil { ctx.Flash.Error("DeletePublicKey: " + err.Error()) @@ -360,6 +374,7 @@ func DeleteSSHKey(ctx *context.Context) { }) } +// SettingsApplications render user's access tokens page func SettingsApplications(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsApplications"] = true @@ -371,9 +386,10 @@ func SettingsApplications(ctx *context.Context) { } ctx.Data["Tokens"] = tokens - ctx.HTML(200, SETTINGS_APPLICATIONS) + ctx.HTML(200, tplSettingsApplications) } +// SettingsApplicationsPost response for add user's access token func SettingsApplicationsPost(ctx *context.Context, form auth.NewAccessTokenForm) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsApplications"] = true @@ -385,7 +401,7 @@ func SettingsApplicationsPost(ctx *context.Context, form auth.NewAccessTokenForm return } ctx.Data["Tokens"] = tokens - ctx.HTML(200, SETTINGS_APPLICATIONS) + ctx.HTML(200, tplSettingsApplications) return } @@ -404,6 +420,7 @@ func SettingsApplicationsPost(ctx *context.Context, form auth.NewAccessTokenForm ctx.Redirect(setting.AppSubUrl + "/user/settings/applications") } +// SettingsDeleteApplication response for delete user access token func SettingsDeleteApplication(ctx *context.Context) { if err := models.DeleteAccessTokenByID(ctx.QueryInt64("id")); err != nil { ctx.Flash.Error("DeleteAccessTokenByID: " + err.Error()) @@ -416,6 +433,7 @@ func SettingsDeleteApplication(ctx *context.Context) { }) } +// SettingsDelete render user suicide page and response for delete user himself func SettingsDelete(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsDelete"] = true @@ -423,7 +441,7 @@ func SettingsDelete(ctx *context.Context) { if ctx.Req.Method == "POST" { if _, err := models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil { if models.IsErrUserNotExist(err) { - ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_DELETE, nil) + ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), tplSettingsDelete, nil) } else { ctx.Handle(500, "UserSignIn", err) } @@ -448,5 +466,5 @@ func SettingsDelete(ctx *context.Context) { return } - ctx.HTML(200, SETTINGS_DELETE) + ctx.HTML(200, tplSettingsDelete) } |