diff options
author | slene <vslene@gmail.com> | 2014-03-16 21:07:50 +0800 |
---|---|---|
committer | slene <vslene@gmail.com> | 2014-03-16 21:07:50 +0800 |
commit | f6e32b1b08a5eff2c0cbdfe827b40fdea9dc676e (patch) | |
tree | 12abcc1c0c3c35de5e45d0c6332819d724c71de6 /routers | |
parent | 0754dd2f955c70994753cd18228333ca32ceee72 (diff) | |
download | gitea-f6e32b1b08a5eff2c0cbdfe827b40fdea9dc676e.tar.gz gitea-f6e32b1b08a5eff2c0cbdfe827b40fdea9dc676e.zip |
finish delete ssh key and delete account. all with confirm.
Diffstat (limited to 'routers')
-rw-r--r-- | routers/user/user.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/routers/user/user.go b/routers/user/user.go index b87076d9e8..ad84ff6c79 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -157,18 +157,28 @@ func Delete(ctx *middleware.Context) { return } - if err := models.DeleteUser(ctx.User); err != nil { + rawPasswd := ctx.Query("password") + encodedPwd, _ := models.EncodePasswd(rawPasswd) + if len(encodedPwd) == 0 || encodedPwd != ctx.User.Passwd { ctx.Data["HasError"] = true - switch err.Error() { - case models.ErrUserOwnRepos.Error(): - ctx.Data["ErrorMsg"] = "Your account still have ownership of repository, you have to delete or transfer them first." - default: - ctx.Handle(200, "user.Delete", err) + ctx.Data["ErrorMsg"] = "Your password error. Make sure you are owner of this account." + } else { + if err := models.DeleteUser(ctx.User); err != nil { + ctx.Data["HasError"] = true + switch err { + case models.ErrUserOwnRepos: + ctx.Data["ErrorMsg"] = "Your account still have ownership of repository, you have to delete or transfer them first." + default: + ctx.Handle(200, "user.Delete", err) + return + } + } else { + ctx.Render.Redirect("/") return } } - ctx.Render.Redirect("/", 302) + ctx.Render.HTML(200, "user/delete", ctx.Data) } const ( |