D
D
dfhkjhg2020-08-11 17:28:27
JavaScript
dfhkjhg, 2020-08-11 17:28:27

How to pass data to the front using passport-steam?

const { Router } = require('express')
const passport = require('passport')
const router = Router()

router.get('/steam', passport.authenticate('steam', { 
    failureRedirect: '/' 
}))

router.get('/steam/return', passport.authenticate('steam', { 
    failureRedirect: '/' 
}), (req, res) => {

    console.log(req)
})

router.get('/isLogged', (req, res) => {
    res.status(200).json(req.headers)
})

module.exports = router


How it works

Browser goes to localhost:5000/auth/steam
Node redirects browser to Steam openId
Steam on successful login and granting authorization redirects back to localhost:5000/auth/steam/

return data to the front (I use vuex) or how can / should it be implemented at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bqio, 2020-08-11
@bqio

If the token is passed via hash (#), then using JS you can store the token in localStorage and redirect to the desired page. And from it already take a token from localStorage. The lifetime of the token can also be written to localStorage and simply checked against the real time each time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question