Skip to content

Commit

Permalink
feat: adjust safepage endpoint (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
hunger-programmer committed Feb 7, 2024
1 parent d46c925 commit d01602c
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,30 @@ app.get('/userinfo', (req, res) => {

app.get('/isloggedin', (req, res) => res.send({ isLoggedin: req.isAuthenticated() }));

app.get('/safepage', oauth.passport.authenticate('oauth'), asyncMW(async (req, res, next) => {
const state = {};
if (req.query.state) {
const stateString = Buffer.from(req.query.state, 'base64').toString();
Object.assign(state, JSON.parse(stateString));
}
if (req.query.order_id) {
console.log('Congratulations! You purchased something');
}
if (state.popup) {
res.render('safepage');
} else {
res.redirect('/');
}
}));
app.get('/safepage',
(req, res, next)=>{
if(!req.query.state || !req.query.code){
return res.redirect('/');
}

return next();
},
oauth.passport.authenticate('oauth'),
asyncMW(async (req, res, next) => {
const state = {};
if (req.query.state) {
const stateString = Buffer.from(req.query.state, 'base64').toString();
Object.assign(state, JSON.parse(stateString));
}
if (req.query.order_id) {
console.log('Congratulations! You purchased something');
}
if (state.popup) {
res.render('safepage');
} else {
res.redirect('/');
}
}));

app.get('/session-exchange-safepage', oauth.passport.authenticate('oauth'), asyncMW(async (req, res) => {
const state = {};
Expand Down

0 comments on commit d01602c

Please sign in to comment.