-
Notifications
You must be signed in to change notification settings - Fork 3
Adds ORCID claiming button to search results #509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
codycooperross
wants to merge
1
commit into
master
Choose a base branch
from
orcid-button-search-results
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+30
−7
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,8 @@ | |
| .id { | ||
| color: #3498db !important; | ||
| } | ||
|
|
||
| .divider { | ||
| border-bottom: 1px solid rgb(205, 210, 213); | ||
| margin-top: 1.5rem; | ||
| } | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Guard session() for SSR and consider sync decode to avoid always-null user.
Calling session() at render can break on the server (Cookies/window not available) and, as implemented, verify() with a callback likely returns before setting user, yielding null. This can hide the button unintentionally.
Minimal guard in this component:
If session() is using asynchronous verification, please switch to a synchronous decode/verify (no callback) or a lightweight decode (e.g., jwt-decode) on the client. I can open a follow-up PR to adjust session() accordingly.
Run this script to confirm the async verify pattern in session.ts:
🏁 Script executed:
Length of output: 970
🏁 Script executed:
Length of output: 970
Ensure
session()is synchronous and guard against SSR to correctly display the ORCID buttonThe current
session()implementation usesJsonWebToken.verifywith a callback, so it always returnsnull(the callback runs after return). Additionally, callingsession()during SSR may throw ifwindow/cookies aren’t available.• src/utils/session.ts
export const session = (): User => { if (!JWT_KEY) return null const sessionCookie = Cookies.getJSON('_datacite') const token = sessionCookie?.authenticated?.access_token if (!token) return null - let user: any = null - function setUser(error: any, payload: any) { - if (error) { - console.log('JWT verification error: ' + error.message) - return - } - - user = payload - } - - JsonWebToken.verify(token, JWT_KEY, { algorithms: ['RS256'] }, setUser) - - return user as User + try { + return JsonWebToken.verify(token, JWT_KEY, { algorithms: ['RS256'] }) as User + } catch (err) { + console.error('JWT verification error:', err) + return null + } }• src/components/WorkMetadata/WorkMetadata.tsx
Let me know if you’d like assistance wiring up a React hook or using
jwt-decodefor a lighter client‐side implementation.📝 Committable suggestion
🤖 Prompt for AI Agents