Skip to content

Add minimum server version check during login#1146

Merged
rolandgeider merged 6 commits intowger-project:masterfrom
darshAnup24:feature/min-server-version-check
Mar 21, 2026
Merged

Add minimum server version check during login#1146
rolandgeider merged 6 commits intowger-project:masterfrom
darshAnup24:feature/min-server-version-check

Conversation

@darshAnup24
Copy link
Contributor

@darshAnup24 darshAnup24 commented Mar 11, 2026

The app already checks a minimum app version from the server, but the
opposite wasn't true — an app could connect to an older server with a
different API without any warning.

This adds a MIN_SERVER_VERSION constant in the app that is checked
against the server version (already fetched in AuthProvider) during
both login() and tryAutoLogin(). If the server is too old, the user
is silently logged out and returned to the auth screen to connect to
a compatible server.

Includes unit tests for version string parsing (including Python-style
pre-release versions like '2.5.0a2').

Closes #1127

Proposed Changes

  • Add MIN_SERVER_VERSION constant to lib/helpers/consts.dart

  • Add serverUpdateRequired() method to AuthProvider that parses and
    compares the already-fetched serverVersion against MIN_SERVER_VERSION

  • Call the check in both login() and tryAutoLogin(); silently logout
    if the server is too old

  • Guard auth_screen.dart to only push UpdateAppScreen for genuine
    app-update cases, not server-version logouts

  • Add 11 unit tests covering normal, edge, and malformed version strings

Related Issue(s)

Closes #1127

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Set a 100-character limit to avoid white space diffs (run dart format .)

The app already checks a minimum app version from the server, but the
opposite wasn't true — an app could connect to an older server with a
different API without any warning.

This adds a MIN_SERVER_VERSION constant in the app that is checked
against the server version (already fetched in AuthProvider) during
both login() and tryAutoLogin(). If the server is too old, the user
is silently logged out and returned to the auth screen to connect to
a compatible server.

Includes unit tests for version string parsing (including Python-style
pre-release versions like '2.5.0a2').

Closes #<issue-number>
@rolandgeider
Copy link
Member

Thanks for the PR!

One thing we definitely need is some kind of UI feedback for the user (we can use something similar to the current min app version check), otherwise the users can't tell if this is a bug or they need to do something, like updating their server.

@darshAnup24
Copy link
Contributor Author

sure I'll see it and update your regarding the same.

darshAnup24 and others added 4 commits March 12, 2026 22:34
- Enhanced version parsing to handle Python/Django version formats more reliably
- Added serverUpdateRequired AuthState for proper UI routing
- Improved server version sanitization with better regex patterns
- Added UpdateServerScreen with localized user feedback
- Integrated into auth flow routing to show appropriate update messages
@darshAnup24
Copy link
Contributor Author

The UI feedback is implemented following the same pattern as the existing min app version check:

Added AuthState.serverUpdateRequired — a new auth state that mirrors AuthState.updateRequired
Created UpdateServerScreen (update_server_screen.dart) — shows an AlertDialog with the message: "The connected server is too old for this version of the app. Please ask the server administrator to update to at least version 2.4."

Wired into main.dart so auto-login routes to the screen on startup

Wired into auth_screen.dart so manual login navigates to the screen after pressing login

The flow mirrors UpdateAppScreen exactly — same dialog style, same routing pattern, just pointing the user at the server admin instead of the app store.

@darshAnup24
Copy link
Contributor Author

I saw the error and this Fixes flaky API-token login test in test/auth/auth_screen_test.dart.

  • Moved API-token mode assertions (inputApiToken visible, username/password hidden) to before submit.
  • Kept post-submit checks focused on behavior (no error and token-auth request verification).

This prevents false negatives when the auth form rebuilds/resets after successful submit.

@rolandgeider rolandgeider merged commit 54a6db2 into wger-project:master Mar 21, 2026
2 checks passed
@rolandgeider
Copy link
Member

merged, thanks!

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.

Check min server version

2 participants