Commit Graph

172 Commits

Author SHA1 Message Date
Matthieu B
7803cfd74c Keep invite form open on errors
Keep form-based invitation screens open on account creation failures so users can see errors without replaying the welcome animation.

Centralize join form template context, preserve theming across invite routes, and add regression coverage for validation and E2E flows.
2026-07-05 18:53:49 +02:00
Matthieu B
31005dcf87 Fix recent onboarding and media-server bugs (#1318)
* fix: resolve button widget context URLs

Fixes #1280

* fix: return relative invitation API URLs

Fixes #1262

* fix: use modern Jellyfin auth headers

Fixes #1309

* fix: use Emby library GUIDs for access policy

Fixes #1303
2026-07-05 18:14:39 +02:00
Danni Croax
8e680388dd fix: handle multi-plex oauth invites 2026-06-06 12:40:31 +00:00
Matthieu B
4847133026 fix: restore get_recent_items parameter names broken by linting pass
Commit 73c29458f renamed library_id/limit to _library_id/_limit to
suppress ARG002 warnings, but the widget caller passes them as keyword
arguments (limit=6), causing a silent TypeError that returns empty data.

Closes #1207
2026-04-01 22:29:39 +02:00
Matthieu B
59e2cb8199 chore: merge main into ldap branch, resolve conflicts 2026-03-29 16:28:20 +02:00
Matthieu B
77e738f9d7 Merge pull request #1202 from wizarrrr/fix/1195-emby-library-mapping
fix: correct Emby library ID mapping and prevent silent folder fallback (#1195)
2026-03-29 16:25:45 +02:00
Matthieu B
14df208566 Merge pull request #1201 from wizarrrr/fix/1168-plex-reinvite-update
fix: update existing Plex share on re-invite instead of failing
2026-03-29 16:25:43 +02:00
Matthieu B
73c29458fe fix: resolve all test failures, linting errors, and type errors
- Fix 55 test failures caused by missing request contexts and incorrect
  session_transaction() usage across 8 test files
- Fix ruff import sorting errors and unused imports
- Fix 122 type errors: rename method override parameters to match base
  classes, add None guards for fetchone()/datetime, widen dict type
  annotations, add type: ignore for SQLAlchemy stub limitations
- Add [tool.ty.rules] config to suppress unsupported-base warnings
- Fix _ variable shadowing gettext in wizard routes
- Add noqa: ARG002 for unused method arguments required by base class
2026-03-29 16:20:23 +02:00
Matthieu B
672475469d fix(ldap): security, architecture, and code quality improvements
- Fix SUBTREE→BASE scope in _fetch_user_attributes (security)
- Remove is_ldap_user threading from all 8 media client interfaces;
  set flag after join via workflow-level User.query.update instead
- Use find_user_dn (search-based) instead of build_user_dn (concatenation)
  in delete_user and reset_user_password for robustness
- Wrap all user-facing strings in _() for i18n in ldap_auth.py
- Fix username fallback from hardcoded "wizarr" to unique per-user
- Return failure from _update_existing_user when password update fails
- Replace dynamic Tailwind classes with explicit conditionals in alert
- Add stale group cleanup and upsert in sync_ldap_groups
- Remove fake @ldap.local email fallback in user_sync
2026-03-29 16:18:41 +02:00
Matthieu B
e9f3c24581 fix: correct Emby library ID mapping and prevent silent folder fallback (#1195)
- Change EmbyClient.libraries() to return {Id: Name} instead of {Guid: Name}
  so Library.external_id stores the value Emby's EnabledFolders policy field
  expects, matching what JellyfinClient._set_specific_folders() resolves.
- Change EmbyClient.scan_libraries() to return {Name: Id} instead of
  {Name: Guid} for the same reason.
- Override _set_specific_folders() in EmbyClient with a mapping that includes
  {Name: Id}, {Id: Id}, and {Guid: Id} entries, providing backwards
  compatibility for existing Library records that still hold a Guid.
- In both EmbyClient._set_specific_folders() and the inherited
  JellyfinClient._set_specific_folders(), when the input names list is
  non-empty but all lookups fail (folder_ids ends up empty), log a structured
  WARNING via structlog and set EnableAllFolders: False with an empty
  EnabledFolders list — restricting access to nothing — rather than silently
  falling back to EnableAllFolders: True which would grant full access.
- Replace inline debug logging.info() calls with structlog structured events.
2026-03-29 16:15:37 +02:00
Matthieu B
751bfb67dd fix: update existing Plex share on re-invite instead of failing (#1168)
When a user who already has a Plex share uses a new invite link, the
"already sharing" error from the Plex API is now handled gracefully by
calling update_user_libraries() and update_user_permissions() instead of
propagating the error to the end-user. The route layer also switches to
a generic, translatable user-facing error message backed by structlog for
admin-visible diagnostics.
2026-03-29 16:15:24 +02:00
Matthieu B
498886c06a fix(ldap): address security, correctness, and code quality issues
Security:
- Fix XSS in HTMX responses by replacing f-string HTML with Jinja partials
- Fix TLS verify_cert not being applied (add Tls config to ldap3 Server)
- Fix password_hash NOT NULL conflict for LDAP-only admin accounts
- Fix should_create_ldap_user defaulting to True for existing invitations

Correctness:
- Fix DN reconstruction fragility using escape_rdn for special characters
- Fix connection leaks with try/finally in all LDAPClient methods
- Fix sync interval logic (check FLASK_ENV not WIZARR_ENABLE_SCHEDULER)
- Only register LDAP sync job when LDAP is actually configured
- Make find_user_dn and service_connection public API methods

Cleanup:
- Squash 5 incremental LDAP migrations into single 20251226_add_ldap_support
- Remove duplicate imports/queries in auth routes
- Replace f-string logging with %s formatting
- Extract inline HTML to Jinja template partials
2026-03-29 15:58:09 +02:00
Erwan Leboucher
5bb51e0cf1 feat(ldap): add LDAP authentication and invitation integration 2025-12-27 17:14:17 +01:00
Matthieu B
89762d96dd feat: add bundle preview functionality and improve token generation tests
- Added a preview link for bundles in the wizard settings page. closes #1048
- Enhanced the wizard steps template to handle bundle preview mode.
- Updated JavaScript to generate URLs for bundle preview and runtime modes.
- Improved test coverage for password reset token generation by asserting token creation.
2025-12-09 14:37:39 +01:00
Matthieu B
ac36e793e1 refactor: improve code formatting and readability across multiple files 2025-12-09 14:12:17 +01:00
Matthieu B
0b2c90fee2 Merge pull request #1020 from 6im0n/feature/reset-password
Feat/Adds password reset functionality for Jellyfin user
2025-12-04 12:02:08 +00:00
Simon
1afa37939a feat: Apply max_active_sessions to Jellyfin user policy 2025-11-21 23:50:04 +01:00
Simon
00f3ef95c3 feat: Implement link password reset functionality 2025-11-21 00:16:24 +01:00
Simon
930b1c1a2c feat: Implements password reset functionality.
- A new API endpoint for requesting a password reset token, which can be accessed either through an API key or an authenticated session.
- A public route for handling the password reset process using the generated token.
- Updates media client to allow password resets.
2025-11-21 00:15:09 +01:00
Simon
fe57277b29 feat: Adds password reset functionality for Jellyfin defintion function 2025-11-21 00:14:29 +01:00
Matthieu B
bf223c894e Add delay to prevent hammering the media server's database during user deletion and disabling
Increase request timeout for media client API calls to  improve reliability closes #995 closes #1014
2025-11-19 15:10:29 +01:00
Matthieu B
96e2bb8e72 fix: update user fetching method to use API call during invitation acceptance
chore: add peer flag to tailwindcss license entry in package-lock.json
2025-11-06 12:21:55 +01:00
Matthieu B
af6a74d6b8 fix: improve error message handling in extract_plex_error_message and use library names in _invite_user closes #975 2025-11-03 18:35:34 +01:00
Matthieu B
0b04a5f520 feat: improve user deletion process and fix foreign key constraints 2025-11-03 14:48:50 +01:00
Matthieu B
0050f4b646 feat: allow user edit 2025-11-03 14:36:04 +01:00
Matthieu B
eca653b10b fix: kavita api errors closes #952 2025-10-27 15:04:24 +01:00
Matthieu B
3d97dda0fb fix: error in nwo playing cards 2025-10-23 20:10:04 +02:00
Matthieu B
6a3632ec66 refactor: update type hints for better clarity and consistency across multiple files 2025-10-23 19:49:58 +02:00
Matthieu B
e70263deab refactor: streamline conditional checks and improve logging clarity 2025-10-23 18:44:30 +02:00
Matthieu B
9b5aa0972a refactor: remove slop from media and new linting rules 2025-10-23 18:33:50 +02:00
Matthieu B
07166a1a80 refactor: update Emby collector to use Sessions API polling instead of WebSocket
fix: correct key for transcoding info in admin routes
feat: enhance Jellyfin client to extract additional session and media details
fix: update template to reflect changes in transcoding info structure
chore: update submodule reference for plus
2025-10-21 11:48:07 +02:00
Matthieu B
03362b0617 fix: Update Plex avatar URL handling to use public URLs directly, removing the need for a proxy 2025-10-19 16:48:26 +02:00
Matthieu B
6ab5e024db Revert "Merge pull request #925 from wizarrrr/chore/python-3.14-upgrade"
This reverts commit 35dde7c19a, reversing
changes made to c8cf9905ba.
2025-10-19 14:05:59 +02:00
Matthieu B
36227c762b refactor: Update type hints for user details methods and other functions for improved clarity 2025-10-18 17:42:26 +02:00
Matthieu B
42d4b56df1 Merge branch 'main' into plus 2025-10-18 16:07:43 +02:00
engels74
d0df4c6d5d feat: wizard step refactor into pre/post wizard steps
Changes:
  - Pre/post invitation wizard phases
  - Phase-aware routing (/pre-wizard/*, /post-wizard/*)
  - Phase indicator badges (visual categorization)
  - Dynamic completion button behavior
  - Two-column admin layout with category drag-and-drop
  - Invite code management service
  - Enhanced wizard export/import
  - Comprehensive test coverage (17 new test files)
2025-10-16 15:28:48 +02:00
Matthieu B
0ac98355dd feat(activity): Implement activity ingestion, identity resolution, and maintenance services
- Added `identity_resolution.py` for resolving Wizarr users and identities.
- Created `ingestion.py` to handle recording and updating activity events.
- Introduced `maintenance.py` for cleanup and session management tasks.
- Developed `queries.py` for read-oriented operations on activity sessions.
- Implemented background tasks in `activity.py` for scheduled maintenance.
- Added tests for activity services and blueprint to ensure functionality.
2025-10-16 15:18:31 +02:00
Matthieu B
17e5b26703 Add identity links to activity sessions and drop ended_at column
- Added columns `wizarr_user_id` and `wizarr_identity_id` to the `activity_session` table.
- Created foreign key constraints for the new columns linking to `user` and `identity` tables.
- Created indexes for the new columns to improve query performance.
- Dropped the `ended_at` column from the `activity_session` table.
- Added a new `active` column to the `activity_session` table with a default value of true.
- Created an index for the `active` column to enhance query efficiency.
2025-10-15 12:52:06 +02:00
Mully
4996b1c8f3 fix: separate disable and enable
+ Much clearer separation of enable and disable (fixing the earlier terrible idea)

+ Audiobookshelf, jellyfin and romm now have enable user logic in the enable_user func
2025-10-10 10:45:40 -04:00
Mully
104c529fba fix: linting error regarding imports 2025-10-10 10:23:15 -04:00
Mully
41125723b8 fix: linting errors 2025-10-10 10:15:12 -04:00
Mully
73e1e12629 feat: enable user endpoint
+ POST /users/<user_id>/enable added

+ Most service's enable_user implementation informs the user that enabling is not supported

+ Audiobookshelf, Jellyfin and RomM can now both disable and enable users

+ Since the few platforms that natively support disabling/enabling users use the same endpoints, disable_user has been given an optional boolean param called enable which defaults to false. This reduces the need of any working enable_user funcs to have a nearly identical implementation.
2025-10-10 10:00:17 -04:00
Mully
28dbb3516f fix: update args doc for new arg 2025-10-10 09:11:19 -04:00
Mully
a87d1d7c23 fix: disable Jellyfin user
+ Jellyfin's disable_user now fetches raw user from Jellyfin for the user's original policies, then updates IsDisabled to true

+ Optional parameter "enable" added, default false (for future use with enable endpoint)
2025-10-10 09:10:27 -04:00
Matthieu B
53d3370d48 feat: Improve user ID resolution in AudiobookshelfClient and update local username mapping 2025-10-09 12:14:27 +02:00
Matthieu B
813601d37b feat: Add Wizarr Plus licensing and historical data import features
- Implemented LicenseValidationMiddleware for periodic license validation and feature protection.
- Created HistoricalDataService for importing historical viewing data from Plex into the ActivitySession model.
- Added KeygenLicenseService for runtime license verification and machine fingerprinting.
- Introduced new Jinja filters for built-in functions max and min.
- Updated settings UI to include a tab for Plus features.
- Added Docker support for Wizarr Plus with a dedicated docker-compose file.
- Created entrypoint script for license verification and initialization of the Wizarr Plus container.
- Added wrapper scripts for building, verifying licenses, and setting up Wizarr Plus.
- Updated dependencies in pyproject.toml to include websocket-client for Plus features.
2025-10-09 12:14:27 +02:00
Matthieu B
c0db3097bd feat: enhance server health metrics and image proxy token management 2025-10-08 17:16:42 +02:00
Matthieu B
e38a699d5e fix: enhance library access resolution for Plex users and update user details structure closes #892. Remove dev dependencies by default closes #905 2025-10-08 11:11:47 +02:00
Matthieu B
8c18977094 feat: enhance Komga integration with API key updates and user management improvements closes [BUG] Komga Setup Returning a 401 error when Komga is set up and working fine
Fixes #693
2025-10-06 12:32:37 +02:00
Matthieu B
290b5f34d1 fix: implement image proxy token generation for now playing cards closes and fixes #891 2025-10-06 10:44:06 +02:00