OI-34 Changing code to only allow stewards to log in - #18
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the ORCID authentication/session flow to enforce steward-only access, improve handling of expired sessions, and surface backend-provided login failure reasons to the user. It also pins the Yarn version via packageManager for more reproducible installs.
Changes:
- Refactors token validation to gate on presence of an ORCID access token (not
hasValidTokens) and preserves the backend response shape instate.user. - Adds session-expiry parsing via
expiresat, uses the steward endpoint for session refresh, and syncs expiry back into in-memory state. - Displays login refusal reasons in the ORCID login header UI and clears stale errors on new login attempts.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/views/pagedecorators/headercomponents/OrcidLogin.vue | Clears prior auth errors on login and displays backend refusal messages in the header UI. |
| src/stores/auth.store.js | Updates validation gating, introduces session-expiry parsing, switches refresh to steward endpoint, and syncs expiry data. |
| package.json | Pins Yarn via packageManager for consistent dependency installs. |
Suppressed comments (1)
src/stores/auth.store.js:163
- Avoid side effects inside computed getters. Calling
logoutTokens()from withinhasValidTokenscan cause surprising cascades (it mutates reactive state during evaluation) and makes the computed non-pure. Prefer returningfalsehere and triggering logout from an explicit action (e.g.,refreshSession, a watcher, or request error handling).
const expiresAt = sessionExpiry()
if (expiresAt !== null && Date.now() >= expiresAt) {
console.log('Neotoma session has expired')
logoutTokens()
return false
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
18
to
+22
| const user = ref(null) | ||
| const isValidating = ref(false) | ||
|
|
||
| // Get the store functions and state: | ||
| const { access_token, fetchTokens, logoutTokens, hasValidTokens } = useTokens() | ||
| const { access_token, error, fetchTokens, logoutTokens, hasValidTokens } = useTokens() |
Comment on lines
+155
to
+160
| // The API enforces expiry on every request; this is the local check so the | ||
| // header doesn't advertise a session that's already dead. Sessions minted | ||
| // before the API returned expiresat have no expiry here — those fall back | ||
| // to being caught by the first 401. | ||
| const expiresAt = sessionExpiry() | ||
| if (expiresAt !== null && Date.now() >= expiresAt) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the authentication flow and user feedback for ORCID logins, focusing on session expiry handling, error messaging, and consistency of user state. The main changes clarify session validation logic, ensure error messages are visible to users, and synchronize session expiry information with the backend.
Authentication and session management improvements:
useTokensto check for the presence of an ORCID token rather than relying onhasValidTokens, preventing stale or expired sessions from blocking new logins and avoiding accidental token clearing.sessionExpiryhelper to consistently parse and check session expiry from the backend, ensuring that local session checks align with backend enforcement and that expired sessions are correctly detected and handled./v2.0/apps/orcids/stewardendpoint and synchronize the session's expiry time in state with the server, so the frontend always checks the latest expiry.User feedback and error handling:
OrcidLogin.vue), clearing old errors on new login attempts and displaying styled error messages when login is refused. [1] [2] [3] [4]Tooling:
package.jsonfor reproducible installs.