Skip to content

Commit

Permalink
update to the user resolvers for google and orcid providers
Browse files Browse the repository at this point in the history
  • Loading branch information
thinknoack committed Jan 7, 2025
1 parent eaa3672 commit 5dda174
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ GOOGLE_CLIENT_SECRET=

[podman-compose](https://github.com/containers/podman-compose) is used to run a local copy of all required services together.

#### macOS Development Setup
#### macOS Development Setup

If you're working on macOS and encounter issues with file watching in Vite, use the following environment variables (in config.env):

```
Expand Down
8 changes: 6 additions & 2 deletions packages/openneuro-server/src/graphql/resolvers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
*/
import User from "../../models/user"

export const user = (obj, { id }) => {
export const user = (obj, { id, key }) => {
function isValidOrcid(orcid: string): boolean {
return /^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9X]$/.test(orcid || "")
}

if (isValidOrcid(id)) {
return User.findOne({ "orcid": id }).exec()
if (key === "orcid") {
return User.findOne({ "orcid": id }).exec()
} else {
return User.findOne({ "providerId": id }).exec()
}
} else {
return User.findOne({ "id": id }).exec()
}

Check warning on line 19 in packages/openneuro-server/src/graphql/resolvers/user.ts

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-server/src/graphql/resolvers/user.ts#L7-L19

Added lines #L7 - L19 were not covered by tests
Expand Down

0 comments on commit 5dda174

Please sign in to comment.