### TL;DR
Added session cleanup logic to handle active organization reassignment when user organizations are deleted.
### What changed?
Enhanced the `cleanupUserOrganizations` method in `AuthService` to reassign active organizations for users whose current active organization is being deleted. The method now:
- Identifies users who are members of organizations being deleted
- Finds alternative organizations for each affected user
- Updates their sessions to use a fallback organization or null if no alternatives exist
- Wraps the entire operation in a database transaction for consistency
### How to test?
Run the new test suite:
```bash
bun test app/server/modules/auth/__tests__/auth.cleanup-user-organizations.test.ts
```
The test verifies that when a user's organization is deleted, other members' sessions are properly updated to use their remaining organization memberships as the active organization.
### Why make this change?
Prevents orphaned session references when organizations are deleted. Without this change, users could have sessions pointing to non-existent organizations as their active workspace, leading to potential application errors or inconsistent state.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
## Release Notes
* **Bug Fixes**
* Improved organization deletion handling. When an organization is deleted, user sessions are now automatically reassigned to a valid fallback organization, ensuring session state consistency and preventing invalid organization references.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* New CLI command to change user email addresses with impact preview and validation.
* **Accessibility**
* Improved settings form with proper label-input associations and email field type validation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
test: use better-auth built-in test plugin
refactor: map auth errors server side
refactor: native trusted providers callback usage
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
## Release Notes
* **New Features**
* Enhanced SSO authentication error messaging with specific guidance for different failure scenarios (account linking required, email verification needed, banned accounts, invite-only access).
* **Chores**
* Updated authentication dependencies to version 1.5.0.
* **Tests**
* Extended test coverage for SSO error code handling and authentication scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Closes#590
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
* **Tests**
* Enhanced test coverage for backup pattern handling and anchoring
* Added end-to-end scenarios validating include patterns, exclusion patterns, and exclude-if-present functionality
* **Refactor**
* Updated pattern processing logic to improve relative path resolution for backup patterns
* Improved asynchronous handling in backup initialization workflow
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
### TL;DR
Added session cleanup logic to handle active organization reassignment when user organizations are deleted.
### What changed?
Enhanced the `cleanupUserOrganizations` method in `AuthService` to reassign active organizations for users whose current active organization is being deleted. The method now:
- Identifies users who are members of organizations being deleted
- Finds alternative organizations for each affected user
- Updates their sessions to use a fallback organization or null if no alternatives exist
- Wraps the entire operation in a database transaction for consistency
### How to test?
Run the new test suite:
```bash
bun test app/server/modules/auth/__tests__/auth.cleanup-user-organizations.test.ts
```
The test verifies that when a user's organization is deleted, other members' sessions are properly updated to use their remaining organization memberships as the active organization.
### Why make this change?
Prevents orphaned session references when organizations are deleted. Without this change, users could have sessions pointing to non-existent organizations as their active workspace, leading to potential application errors or inconsistent state.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
## Release Notes
* **Bug Fixes**
* Improved organization deletion handling. When an organization is deleted, user sessions are now automatically reassigned to a valid fallback organization, ensuring session state consistency and preventing invalid organization references.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* New CLI command to change user email addresses with impact preview and validation.
* **Accessibility**
* Improved settings form with proper label-input associations and email field type validation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
test: use better-auth built-in test plugin
refactor: map auth errors server side
refactor: native trusted providers callback usage
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
## Release Notes
* **New Features**
* Enhanced SSO authentication error messaging with specific guidance for different failure scenarios (account linking required, email verification needed, banned accounts, invite-only access).
* **Chores**
* Updated authentication dependencies to version 1.5.0.
* **Tests**
* Extended test coverage for SSO error code handling and authentication scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Closes#590
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **Tests**
* Enhanced test coverage for backup pattern handling and anchoring
* Added end-to-end scenarios validating include patterns, exclusion patterns, and exclude-if-present functionality
* **Refactor**
* Updated pattern processing logic to improve relative path resolution for backup patterns
* Improved asynchronous handling in backup initialization workflow
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Allows users to pass arbitrary restic flags via a new advanced section in the create/edit schedule form. Includes DB migration, schema update, DTO, service, and restic command changes.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **Tests**
* Improved test infrastructure and organization across backup, repository, volume, and utility modules with streamlined mock setup and cleaner test patterns.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
refactor(restic): split each command into its own file
refactor: add missing await before promise expects
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
## Release Notes
* **Tests**
* Improved async assertion handling across test suites for enhanced test reliability
* Expanded test coverage for backup, restore, and other core operations
* **Refactor**
* Reorganized internal utility structure for improved code maintainability
* **Chores**
* Updated linting configuration and TypeScript dependencies
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Closes#562
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
## Release Notes
* **New Features**
* Improved repository setup with context-aware descriptions for new vs. existing repositories
* Enhanced path handling: unique identifiers automatically appended for new repositories, exact paths preserved when importing existing ones
* **Chores**
* Updated documentation and build configuration
<!-- end of auto-generated comment: release notes by coderabbit.ai -->