func DeletePost(ctx *middleware.Context) { ctx.Data["Title"] = "Delete Account" ctx.Data["PageIsUserSetting"] = true ctx.Data["IsUserPageSettingDelete"] = true tmpUser := models.User{ Passwd: ctx.Query("password"), Salt: ctx.User.Salt, } tmpUser.EncodePasswd() if tmpUser.Passwd != ctx.User.Passwd { ctx.Flash.Error("Password is not correct. Make sure you are owner of this account.") } else { if err := models.DeleteUser(ctx.User); err != nil { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error("Your account still have ownership of repository, you have to delete or transfer them first.") default: ctx.Handle(500, "user.Delete", err) return } } else { ctx.Redirect("/") return } } ctx.Redirect("/user/delete") }
func Delete(ctx *middleware.Context) { ctx.Data["Title"] = "Delete Account" ctx.Data["PageIsUserSetting"] = true ctx.Data["IsUserPageSettingDelete"] = true if ctx.Req.Method == "GET" { ctx.HTML(200, "user/delete") return } tmpUser := models.User{Passwd: ctx.Query("password")} tmpUser.EncodePasswd() if len(tmpUser.Passwd) == 0 || tmpUser.Passwd != ctx.User.Passwd { ctx.Data["HasError"] = true ctx.Data["ErrorMsg"] = "Password is not correct. 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.Redirect("/") return } } ctx.HTML(200, "user/delete") }
func DeletePost(ctx *middleware.Context, params martini.Params) { ctx.Data["Title"] = "Settings" org, err := models.GetUserByName(params["org"]) if err != nil { if err == models.ErrUserNotExist { ctx.Handle(404, "org.DeletePost(GetUserByName)", err) } else { ctx.Handle(500, "org.DeletePost(GetUserByName)", err) } return } ctx.Data["Org"] = org if !org.IsOrgOwner(ctx.User.Id) { ctx.Error(403) return } tmpUser := models.User{ Passwd: ctx.Query("password"), Salt: ctx.User.Salt, } tmpUser.EncodePasswd() if tmpUser.Passwd != ctx.User.Passwd { ctx.Flash.Error("Password is not correct. Make sure you are owner of this account.") } else { if err := models.DeleteOrganization(org); err != nil { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error("This organization still have ownership of repository, you have to delete or transfer them first.") default: ctx.Handle(500, "org.DeletePost(DeleteOrganization)", err) return } } else { ctx.Redirect("/") return } } ctx.Redirect("/org/" + org.Name + "/settings") }