Soft delete users (#476)

* Update Makefile

* Optionally load test DB from env variable

* Add option to soft-delete a user

This allows users to be marked as deleted.
An additional middleware checks if a user is deleted or deactivated and rejects
requests for those as StatusUnauthorized.

note: the middelware adds an additional DB query to load the user.
This commit is contained in:
Michael Bumann
2024-01-09 19:38:01 +02:00
committed by GitHub
parent a6f493ec20
commit e33693398e
10 changed files with 163 additions and 14 deletions

View File

@@ -19,6 +19,7 @@ type User struct {
Invoices []*Invoice `bun:"rel:has-many,join:id=user_id"`
Accounts []*Account `bun:"rel:has-many,join:id=user_id"`
Deactivated bool
Deleted bool
}
func (u *User) BeforeAppendModel(ctx context.Context, query bun.Query) error {