Skip to content

Commit

Permalink
fix: use TriggerWebhook function instead of NotifyUserChange
Browse files Browse the repository at this point in the history
The `NotifyUserChange` function tries to get the user from the database but since the user was deleted the user is not present anymore and therefore `nil` is returned. To fix it, the account delete event is triggered through `TriggerWebhook`.
  • Loading branch information
FreddyDevelop committed Feb 24, 2025
1 parent c4f4249 commit 4187417
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/flow_api/flow/profile/action_account_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package profile
import (
"fmt"
auditlog "github.com/teamhanko/hanko/backend/audit_log"
"github.com/teamhanko/hanko/backend/dto/admin"
"github.com/teamhanko/hanko/backend/flow_api/flow/shared"
"github.com/teamhanko/hanko/backend/flowpilot"
"github.com/teamhanko/hanko/backend/persistence/models"
Expand Down Expand Up @@ -61,7 +62,11 @@ func (a AccountDelete) Execute(c flowpilot.ExecutionContext) error {
}

deps.HttpContext.SetCookie(cookie)
utils.NotifyUserChange(deps.HttpContext, deps.Tx, deps.Persister, events.UserDelete, userModel.ID)

err = utils.TriggerWebhooks(deps.HttpContext, deps.Tx, events.UserDelete, admin.FromUserModel(*userModel))
if err != nil {
return fmt.Errorf("failed to trrigger webhook: %w", err)
}

return c.Continue(shared.StateProfileAccountDeleted)
}

0 comments on commit 4187417

Please sign in to comment.