Merge pull request #6 from JBB0807/current_user_api

added current user api
This commit is contained in:
JB Balahadia 2025-04-28 14:12:23 -07:00 committed by GitHub
commit 3b57a48fdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 7 deletions

View file

@ -10,6 +10,14 @@ router.get(
})
);
router.get('/current_user', (req, res) => {
if (req.isAuthenticated()) {
res.json(req.user);
} else {
res.status(401).json({ error: 'Not authenticated' });
}
});
router.get("/login", (req, res) => {
if (req.user) {

View file

@ -23,13 +23,13 @@ app.use(
app.use(passport.initialize());
app.use(passport.session());
// app.use(
// cors({
// origin: process.env.ACCEPTED_ORIGINS.split(","),
// methods: "GET",
// credentials: true,
// })
// )
app.use(
cors({
origin: process.env.ACCEPTED_ORIGINS.split(","),
methods: "GET",
credentials: true,
})
)
app.use("/auth", authRoute);