feat: notify user on account deletion
All checks were successful
Deploy / build-and-deploy (push) Successful in 1m45s
All checks were successful
Deploy / build-and-deploy (push) Successful in 1m45s
This commit is contained in:
parent
2db260f849
commit
43e6f76c01
12 changed files with 294 additions and 19 deletions
|
|
@ -77,13 +77,36 @@ func (h *settingsHandler) DeleteAccount(w http.ResponseWriter, r *http.Request)
|
|||
http.Redirect(w, r, "/account-pending-deletion", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
func (h *settingsHandler) AccountDeletionStatusPage(w http.ResponseWriter, r *http.Request) {
|
||||
requestID := r.PathValue("requestID")
|
||||
if requestID == "" {
|
||||
ui.Render(w, r, pages.NotFound())
|
||||
return
|
||||
}
|
||||
|
||||
req, err := h.userService.GetDeletionRequest(requestID)
|
||||
if err != nil {
|
||||
slog.Info("account deletion status lookup failed",
|
||||
"request_id", requestID,
|
||||
"error", err,
|
||||
)
|
||||
ui.Render(w, r, pages.NotFound())
|
||||
return
|
||||
}
|
||||
ui.Render(w, r, pages.AccountDeletionStatus(req))
|
||||
}
|
||||
|
||||
func (h *settingsHandler) AccountPendingDeletionPage(w http.ResponseWriter, r *http.Request) {
|
||||
user := ctxkeys.User(r.Context())
|
||||
if user == nil || !user.IsPendingDeletion() {
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
ui.Render(w, r, pages.AccountPendingDeletion(*user.PendingDeletionAt))
|
||||
trackingID := ""
|
||||
if req, err := h.userService.LatestDeletionRequestForUser(user.ID); err == nil {
|
||||
trackingID = req.ID
|
||||
}
|
||||
ui.Render(w, r, pages.AccountPendingDeletion(*user.PendingDeletionAt, trackingID))
|
||||
}
|
||||
|
||||
func (h *settingsHandler) SetPassword(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ func newTestSettingsHandler(dbi testutil.DBInfo) (*settingsHandler, *service.Aut
|
|||
accountSvc := service.NewAccountService(accountRepo)
|
||||
emailSvc := service.NewEmailService(nil, "test@example.com", "http://localhost:9999", "Budgit Test", false)
|
||||
authSvc := service.NewAuthService(emailSvc, userRepo, tokenRepo, spaceSvc, accountSvc, cfg.JWTSecret, cfg.JWTExpiry, cfg.TokenMagicLinkExpiry, false, false)
|
||||
userSvc := service.NewUserService(dbi.DB, userRepo, repository.NewAccountDeletionRequestRepository(dbi.DB))
|
||||
userSvc := service.NewUserService(dbi.DB, userRepo, repository.NewAccountDeletionRequestRepository(dbi.DB), nil)
|
||||
return NewSettingsHandler(authSvc, userSvc), authSvc
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue