Skip to content

Commit

Permalink
feat: disable delete acount button
Browse files Browse the repository at this point in the history
  • Loading branch information
taciturnaxolotl committed Dec 18, 2024
1 parent eb052ae commit 668a61e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
40 changes: 22 additions & 18 deletions routes/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,25 +730,29 @@ func (h *SettingsHandler) actionClearData(w http.ResponseWriter, r *http.Request
}

func (h *SettingsHandler) actionDeleteUser(w http.ResponseWriter, r *http.Request) actionResult {
if h.config.IsDev() {
loadTemplates()
}

user := middlewares.GetPrincipal(r)
go func(user *models.User) {
slog.Info("deleting user shortly", "userID", user.ID)
time.Sleep(5 * time.Minute)
if err := h.userSrvc.Delete(user); err != nil {
conf.Log().Request(r).Error("failed to delete user", "userID", user.ID, "error", err)
} else {
slog.Info("successfully deleted user", "userID", user.ID)
}
}(user)

routeutils.SetSuccess(r, w, "Your account will be deleted in a few minutes. Sorry to see you go.")
http.SetCookie(w, h.config.GetClearCookie(models.AuthCookieKey))
http.Redirect(w, r, h.config.Server.BasePath, http.StatusFound)
// return error cannot delete user contact high seas support for help
routeutils.SetError(r, w, "Cannot delete user. Please contact support for help.")
return actionResult{-1, "", "", nil}

// if h.config.IsDev() {
// loadTemplates()
// }

// user := middlewares.GetPrincipal(r)
// go func(user *models.User) {
// slog.Info("deleting user shortly", "userID", user.ID)
// time.Sleep(5 * time.Minute)
// if err := h.userSrvc.Delete(user); err != nil {
// conf.Log().Request(r).Error("failed to delete user", "userID", user.ID, "error", err)
// } else {
// slog.Info("successfully deleted user", "userID", user.ID)
// }
// }(user)

// routeutils.SetSuccess(r, w, "Your account will be deleted in a few minutes. Sorry to see you go.")
// http.SetCookie(w, h.config.GetClearCookie(models.AuthCookieKey))
// http.Redirect(w, r, h.config.Server.BasePath, http.StatusFound)
// return actionResult{-1, "", "", nil}
}

func (h *SettingsHandler) actionGenerateInvite(w http.ResponseWriter, r *http.Request) actionResult {
Expand Down
9 changes: 8 additions & 1 deletion views/settings.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,12 @@
class="font-semibold text-text-primary dark:text-text-dark-primary"
>Delete Account</span
>
<span
class="block text-sm text-red-600"
>
Warning: Deleting your account is currently disabled during high seas. Please contact us in <a href="https://hackclub.slack.com/archives/C07PZNMBPBN">#high-seas-help</a>
</span>
<br/>
<span
class="block text-sm text-text-secondary dark:text-text-dark-secondary"
>
Expand All @@ -2154,8 +2160,9 @@
<div class="w-1/2 ml-4 flex items-center">
<button
type="button"
class="btn-danger ml-1"
class="btn-danger ml-1 opacity-50 cursor-not-allowed"
@click.stop="confirmDeleteAccount"
disabled
>
Delete account
</button>
Expand Down

0 comments on commit 668a61e

Please sign in to comment.