Skip to content

Commit

Permalink
Added support for dev auth endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
AydanPirani committed Apr 11, 2024
1 parent a8b2cd6 commit f1951fe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ export const Config = {

export const DeviceRedirects: Record<string, string> = {
web: "https://www.google.com/",
dev: "http://127.0.0.1:3000/auth/dev/"

Check failure on line 30 in src/config.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
};
6 changes: 5 additions & 1 deletion src/services/auth/auth-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ authRouter.get(
try {
const jwtPayload = (await getJwtPayloadFromDatabase(userId)).toObject();

Check failure on line 52 in src/services/auth/auth-router.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `await·getJwtPayloadFromDatabase(userId)` with `⏎················await·getJwtPayloadFromDatabase(userId)⏎············`
const token = jsonwebtoken.sign(jwtPayload, Config.JWT_SIGNING_SECRET, { expiresIn: Config.JWT_EXPIRATION_TIME });

Check failure on line 53 in src/services/auth/auth-router.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `jwtPayload,·Config.JWT_SIGNING_SECRET,·{·expiresIn:·Config.JWT_EXPIRATION_TIME·}` with `⏎················jwtPayload,⏎················Config.JWT_SIGNING_SECRET,⏎················{·expiresIn:·Config.JWT_EXPIRATION_TIME·}⏎············`
const redirectUri = `${DeviceRedirects[req.params.DEVICE]}/token=${token}`;
const redirectUri = DeviceRedirects[req.params.DEVICE] + `token=${token}`;

Check failure on line 54 in src/services/auth/auth-router.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `⏎···············`
return res.redirect(redirectUri);
} catch (error) {
next(error);
}
}
);

authRouter.get("/dev/", (req, res) => {
return res.status(StatusCodes.OK).json({"Token": req.headers.authorization});

Check failure on line 63 in src/services/auth/auth-router.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `.status(StatusCodes.OK).json({"Token":·req.headers.authorization` with `⏎········.status(StatusCodes.OK)⏎········.json({·Token:·req.headers.authorization·`
})

Check failure on line 64 in src/services/auth/auth-router.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `;`

export default authRouter;
2 changes: 1 addition & 1 deletion src/services/auth/auth-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function createGoogleStrategy(device: string) {
{
clientID: Config.CLIENT_ID,
clientSecret: Config.CLIENT_SECRET,
callbackURL: `${Config.AUTH_CALLBACK_URI_BASE}${device}`,
callbackURL: Config.AUTH_CALLBACK_URI_BASE + device,
},

// Strategy -> insert user into database if they don't exist
Expand Down

0 comments on commit f1951fe

Please sign in to comment.