I am halfway through implementing Nuxt Auth (local/refresh) in my application. I have a table in the db where I store the refresh tokens and I want to delete the refresh token from the db when Nuxt Auth logs out. Nuxt Auth is not sending the refresh token to my endpoint so there is no way for me to look it up and delete it from the database.
Nuxt Auth is correctly getting both tokens and the user details on login and is correctly calling my logout API endpoint, it is just sending an empty body.
package.json:
"@nuxtjs/auth-next": "^5.0.0-1624817847.21691f1",
nuxt.config:
auth: {
strategies: {
local: {
scheme: 'refresh',
token: {
property: 'accessToken',
maxAge: 1800,
global: true,
},
refreshToken: {
property: 'refreshToken',
data: 'refreshToken',
maxAge: 60 * 60 * 24 * 30
},
endpoints: {
login: {url: '/login', method: 'post'},
refresh: { url: '/token', method: 'post'},
logout: {url: '/logout', method: 'delete'},
user: {url: '/user', method: 'get'}
},
user: {
property: false,
},
tokenRequired: true,
tokenType: 'bearer'
}
}
}
API Endpoint:
router.delete('/logout', async (req, res) => {
const sql =`DELETE FROM tokens WHERE id = '${req.body.refreshToken}'`
await pool.query(sql)
res.sendStatus(204)
})