-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:NYPL/research-catalog into hold-pages
- Loading branch information
Showing
45 changed files
with
2,409 additions
and
1,469 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -89,7 +89,8 @@ Route parameter is the patron ID. Request body can include any fields on the pat | |
exampleBody: { | ||
emails: ['[email protected]'], | ||
phones: [6466600432] | ||
phones: [12345678], | ||
homeLibraryCode: 'sn' | ||
}, | ||
``` | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { NextApiResponse, NextApiRequest } from "next" | ||
import initializePatronTokenAuth from "../../../../src/server/auth" | ||
import { updateUsername } from "../helpers" | ||
|
||
/** | ||
* API route handler for /api/account/username/{patronId} | ||
*/ | ||
export default async function handler( | ||
req: NextApiRequest, | ||
res: NextApiResponse | ||
) { | ||
let responseMessage = "Request error" | ||
let responseStatus = 400 | ||
const patronTokenResponse = await initializePatronTokenAuth(req.cookies) | ||
const cookiePatronId = patronTokenResponse.decodedPatron?.sub | ||
if (!cookiePatronId) { | ||
responseStatus = 403 | ||
responseMessage = "No authenticated patron" | ||
return res.status(responseStatus).json(responseMessage) | ||
} | ||
if (req.method == "GET") { | ||
responseMessage = "Please make a PUT request to this endpoint." | ||
} | ||
if (req.method == "PUT") { | ||
/** We get the patron id from the request: */ | ||
const patronId = req.query.id as string | ||
const { username } = req.body | ||
/** We check that the patron cookie matches the patron id in the request, | ||
* i.e.,the logged in user is updating their own username. */ | ||
if (patronId == cookiePatronId) { | ||
const response = await updateUsername(patronId, username) | ||
responseStatus = response.status | ||
responseMessage = response.message | ||
} else { | ||
responseStatus = 403 | ||
responseMessage = "Authenticated patron does not match request" | ||
} | ||
} | ||
res.status(responseStatus).json(responseMessage) | ||
} |
This file contains 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
This file contains 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
This file contains 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
51 changes: 0 additions & 51 deletions
51
src/components/MyAccount/Settings/AccountSettingsButtons.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.