A starter repository for a front-end Vue.js SPA with a Node.js/Express and mongoDB back-end incl. pre-defined authentication, email verification and delete account functionality.
MIT License
A starter repository for a front-end Vue.js SPA with a Node.js/Express and mongoDB back-end incl. pre-defined authentication, email verification and delete account functionality.
On the front-end Vue has been set up with VueX store and routing including route protection with redirecting. The settings can be expanded further during development. Bootstrap is implemented and can be easily adapted through respective SCSS files.
The starter includes the following views/routes:
and the following components:
The user id, user role and user status are stored in localStorage
to be used session persistent on the client side.
On the back-end a Node.js/Express server is set up. mongoDB serves as the database for user data and can be expanded further. The following routes are set up:
Private routes are protected through 'check authentication' middleware.
The authentication system has been set up with json web token and persistent cookie session in the backend. The token is stored securely in the cookie. CSRF protection through csurf is set up for production.
Email service is provided through nodemailer.
Clone and set up repository or directly use repository as template
Run npm install
in root
and root/client
directory.
Add secrets.json
in root/server/utils
and add secrets and your mongoDB and email hosting data:
{
"MDB_URL": "YOUR_MONGODB_URL_WITH_USERNAME_AND_PASSWORD",
"COOKIE_SESSION_SECRET": "YOUR_SESSION_COOKIE_SECRET",
"JWT_SECRET": "YOUR_JSONWEBTOKEN_SECRET",
"EMAIL_HOST": "YOUR_EMAIL_HOST",
"EMAIL_USERNAME": "YOUR_EMAIL_USERNAME",
"EMAIL_PW": "YOUR_EMAIL_PASSWORD",
"EMAIL_PORT": 000
}
In the default set-up email address verification is obligatory. The default user status after registration is status: "pending"
. You can change to status: "active"
in root/server/utils/models/user.js
to omit email address verification.
MIT