In previous exercises in Chapter 10, Adding a Vuex Store, and Chapter 11, Writing Route Middlewares and Server Middlewares, we used a dummy user for our backend authentication, particularly in /chapter-11/nuxt-universal/route-middleware/per-route/ for per-route middlewares, for example:
// server/modules/public/user/_routes/login.js
router.post('/login', async (ctx, next) => {
let request = ctx.request.body || {}
if (request.username === 'demo' && request.password === 'demo') {
let payload = { id: 1, name: 'Alexandre', username: 'demo' }
let token = jwt.sign(payload, config.JWT_SECRET, { expiresIn: 1 * 60 })
//...
}
})
But in this chapter, we are going to use a database with some user data for authentication. Also, in Chapter 9, Adding a Server-Side Database, we used MongoDB as our database server. But this time, let's try a different database system for the sake of diversity &...