Skip to content

Use gorm.DeletedAt to exclude soft-deleted users from repository lookups - #46

Merged
pikann merged 2 commits into
feature/implement-auth-apisfrom
copilot/sub-pr-44-again
Mar 25, 2026
Merged

pikann merged 2 commits into
feature/implement-auth-apisfrom
copilot/sub-pr-44-again

Conversation

Copilot AI commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

FindByID and FindByUsername were returning soft-deleted users since the manual *time.Time field isn't recognized by GORM's soft-delete machinery — deleted accounts could still authenticate.

Changes

  • userRecord.DeletedAt: switched from *time.Time → gorm.DeletedAt; GORM now automatically appends deleted_at IS NULL to all queries on this model
  • Delete: replaced manual Update("deleted_at", &now) with GORM's built-in db.Delete(&userRecord{})
  • toEntity / fromEntity: convert between gorm.DeletedAt and domain's *time.Time at the repository boundary — domain entity is unchanged
// Before: *time.Time — GORM does not auto-filter on this type
DeletedAt *time.Time `gorm:"index"`

// After: GORM appends `deleted_at IS NULL` to every Find/First query
DeletedAt gorm.DeletedAt `gorm:"index"`

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] [WIP] Address feedback on auth APIs implementation Use gorm.DeletedAt to exclude soft-deleted users from repository lookups Mar 25, 2026
Copilot AI requested a review from pikann March 25, 2026 04:40
@pikann
pikann marked this pull request as ready for review March 25, 2026 04:41
@pikann
pikann merged commit 9ea253d into feature/implement-auth-apis Mar 25, 2026
4 checks passed
@pikann
pikann deleted the copilot/sub-pr-44-again branch March 25, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants