Merge pull request #6 from JBB0807/current_user_api
added current user api
This commit is contained in:
commit
3b57a48fdc
2 changed files with 15 additions and 7 deletions
|
|
@ -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) {
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue