DEV Community

Discussion on: Nuxt.js 2 And Express.js Authentication with Auth Module and JWT

Collapse
 
slidenerd profile image
slidenerd • Edited

nice post! after login you should use router.replace not router.push because if you hit the back button after login you will go back to the login form if you are using push, also in the backend you dont need body-parser anymore, bcryptjs is nice if you dont want dependencies but bcrypt is the way to go for optimal performance, positive note: i have never seen anyone set the access control allow origin headers directly in an express middleware, most examples use the cors module, it didnt occur to me :) you keep learning something new everyday i guess. Another solid suggestion from my end would be to use a relational database for this since the structure of a user (email, password, name) remains the same for each record (it seems in your application that way) you could use the native pg module which requires you to manage connections manually or you could use pg-promise which is very similar to mongoose for postgres database

Collapse
 
mohammadali0120 profile image
MohammadAli Khaksar • Edited

hi, thanks for your good suggestions yeah these days I'm usually using Postgres in my apps, but I just wanted this dummy app would be as easy as it can because almost every Node developer has worked with MongoDB and Mongoose once
and yeah core package is a really good package, and actually, I should use it in my future apps.
and of course router.replace() also would be better way
Thanks for all your goodness, take care of them and also yourself :)

Collapse
 
slidenerd profile image
slidenerd

i am a fullstack developer and i had a lot of trouble in this section due to lack of documentation or examples anywhere on how to use nuxt auth on both the frontend and backend. I really appreciate your effort in putting this up. If it isnt too much to ask, can you please add a part 2 where you add Facebook or Twitter login using nuxt-auth in addition to email password and also use postgres. Super appreciate in advance

Thread Thread
 
mohammadali0120 profile image
MohammadAli Khaksar • Edited

hi, as you say this module does not have many examples or documentation and I actually have no plan to write about Facebook or Google and some stuff like that for authentication
sorry about this, really I don't have time for getting stuck more on this matter
but I introduce to you some examples that might help you.

codesandbox.io/s/kdwxq?file=/nuxt....
codesandbox.io/s/45icg?file=/nuxt....