How do i create a token along with the object and then take that object

how do i create a token along with the object and then take that object

const obj = { "ok": "people" }
auth.generate(user, ????)

after get object

const data = auth.getUser()
// console.log(data.obj) ??????????

Hi!

auth.generate() takes custom payload as second option (if you are using JWT)

const obj = { "ok": "people" }
auth.generate(user, obj)

Later when you want to extract it from token

// https://www.npmjs.com/package/jsonwebtoken (Adonis uses it internally)
const jwt = require('jsonwebtoken') 

var payload = jwt.decode(token)
1 Like

thank’s :upside_down_face::upside_down_face: