Skip to content

Commit

Permalink
feat: flag middleware behind prod node_env
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWu098 committed Aug 29, 2024
1 parent dadcb0e commit e370a78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 9 additions & 9 deletions client/src/utils/auth/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const refreshToken = async () => {
if (currentUser) {
const refreshToken = currentUser.refreshToken;
const {
data: { access_token: idToken },
data: { access_token: id_token },
} = await axios.post(REFRESH_URL, {
grant_type: "refresh_token",
refresh_token: refreshToken,
Expand All @@ -69,18 +69,18 @@ export const refreshToken = async () => {
// Sets the appropriate cookies after refreshing access token
setCookie({
key: cookieKeys.ACCESS_TOKEN,
value: idToken,
value: id_token,
config: cookieConfig,
});

const user = await backend.get(`/users/${auth.currentUser?.uid}`);
setCookie({
key: cookieKeys.ROLE,
value: user.data[0].type,
config: cookieConfig,
});
// const user = await backend.get(`/users/${auth.currentUser?.uid}`);
// setCookie({
// key: cookieKeys.ROLE,
// value: user.data[0].type,
// config: cookieConfig,
// });

return { accessToken: idToken, currentUser: user.data[0] };
return { accessToken: id_token };
}
return null;
};
Expand Down
4 changes: 3 additions & 1 deletion server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ app.use(

app.use(cookieParser());
app.use(express.json());
app.use(verifyToken);
if (process.env.NODE_ENV === "production") {
app.use(verifyToken);
}

app.use("/", sampleRouter); // TODO: delete sample endpoint
app.use("/users", userRouter);
Expand Down

0 comments on commit e370a78

Please sign in to comment.