fix admin database seeding closes #357 #358

Merged
simon merged 3 commits from bugfix/reseeding-database-not-working into main 2026-01-19 14:17:14 +01:00
Owner

Description of the implemented changes

The changes were:

  • Bugfixing
  • New Feature
  • Breaking Change
  • Refactoring

Fix database seeding: Admin user role assignment now works for both newly created users and existing users (e.g., via OIDC). Added support for configurable admin email via environment variable.

What has been changed?

  • Fixed admin user role assignment in seeds:

    • Changed from hardcoded admin@mv.local to configurable admin@localhost (default, can be overridden via ADMIN_EMAIL env var)
    • Fixed Ash.read_one calls to use proper Query syntax with Ash.Query.filter instead of invalid direct filter arguments
    • Seeds now correctly handle existing users (e.g., created via OIDC) by finding them and assigning the admin role
    • Seeds also create admin user with password if user doesn't exist yet
  • Added test for authorization:

    • Created test test/membership/member_test.exs - "user without role cannot create member"
    • Test verifies that users without a role receive Ash.Error.Forbidden.Policy when attempting to create members
    • This test documents the expected behavior and will help catch regressions
  • Documentation updates:

    • Updated docs/development-progress-log.md to reflect new default admin email

Definition of Done

Code Quality

  • No new technical depths
  • Linting passed
  • Documentation is added were needed

Accessibility

  • New elements are properly defined with html-tags
  • Colour contrast follows WCAG criteria
  • Aria labels are added when needed
  • Everything is accessible by keyboard
  • Tab-Order is comprehensible
  • All interactive elements have a visible focus

Testing

  • Tests for new code are written
  • All tests pass
  • axe-core dev tools show no critical or major issues

Additional Notes

  • The seeds script is now idempotent and can be run multiple times safely
  • Admin email can be configured via ADMIN_EMAIL environment variable (defaults to admin@localhost)
  • The fix ensures that users created via OIDC (e.g., admin@localhost) will automatically receive the admin role when seeds are run
  • Changed admin email from admin@mv.local to admin@localhost for better local development compatibility
  • Fixed deprecation warning by keeping type: :append_and_remove (was already correct, no change needed)
## Description of the implemented changes The changes were: - [x] Bugfixing - [ ] New Feature - [ ] Breaking Change - [ ] Refactoring Fix database seeding: Admin user role assignment now works for both newly created users and existing users (e.g., via OIDC). Added support for configurable admin email via environment variable. ## What has been changed? - **Fixed admin user role assignment in seeds:** - Changed from hardcoded `admin@mv.local` to configurable `admin@localhost` (default, can be overridden via `ADMIN_EMAIL` env var) - Fixed `Ash.read_one` calls to use proper Query syntax with `Ash.Query.filter` instead of invalid direct filter arguments - Seeds now correctly handle existing users (e.g., created via OIDC) by finding them and assigning the admin role - Seeds also create admin user with password if user doesn't exist yet - **Added test for authorization:** - Created test `test/membership/member_test.exs` - "user without role cannot create member" - Test verifies that users without a role receive `Ash.Error.Forbidden.Policy` when attempting to create members - This test documents the expected behavior and will help catch regressions - **Documentation updates:** - Updated `docs/development-progress-log.md` to reflect new default admin email ## Definition of Done ### Code Quality - [x] No new technical depths - [x] Linting passed - [x] Documentation is added were needed ### Accessibility - [ ] New elements are properly defined with html-tags - [ ] Colour contrast follows WCAG criteria - [ ] Aria labels are added when needed - [ ] Everything is accessible by keyboard - [ ] Tab-Order is comprehensible - [ ] All interactive elements have a visible focus ### Testing - [x] Tests for new code are written - [x] All tests pass - [ ] axe-core dev tools show no critical or major issues ## Additional Notes - The seeds script is now idempotent and can be run multiple times safely - Admin email can be configured via `ADMIN_EMAIL` environment variable (defaults to `admin@localhost`) - The fix ensures that users created via OIDC (e.g., `admin@localhost`) will automatically receive the admin role when seeds are run - Changed admin email from `admin@mv.local` to `admin@localhost` for better local development compatibility - Fixed deprecation warning by keeping `type: :append_and_remove` (was already correct, no change needed)
simon added 3 commits 2026-01-19 14:11:52 +01:00
simon changed title from closes #357 to fix admin database seeding closes #357 2026-01-19 14:12:11 +01:00
requested review from carla 2026-01-19 14:12:31 +01:00
simon merged commit b84431879c into main 2026-01-19 14:17:14 +01:00
moritz deleted branch bugfix/reseeding-database-not-working 2026-01-20 12:42:03 +01:00
Sign in to join this conversation.
No description provided.