Skip to content

Commit

Permalink
feat: set up new username route with new IDAPI proxy config
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Kabo committed Feb 13, 2024
1 parent 71bc048 commit 77454b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/idapiProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ export const idapiProxyHandler =
url,
method = 'GET',
processData,
sendAuthHeader,
sendAuthHeader = false,
}: {
url: string;
method?: HTTPMethod;
processData?: (json: T, res: Response) => Response | void;
useOAuth?: boolean;
sendAuthHeader: boolean;
sendAuthHeader?: boolean;
}) =>
async (req: Request, res: Response, next: NextFunction) => {
let config;
Expand Down
10 changes: 10 additions & 0 deletions server/routes/idapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ router.delete(
}),
);

router.post(
'/user/username',
csrfValidateMiddleware,
idapiProxyHandler({
url: '/user/me/username',
method: 'POST',
sendAuthHeader: true,
}),
);

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- assume we don't know the range of possible types for the err argument?
router.use((err: any, _: Request, res: Response, next: NextFunction) => {
if (err.code && err.code === 'EBADCSRFTOKEN') {
Expand Down

0 comments on commit 77454b2

Please sign in to comment.