Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

An exercise in full-stack account management, password hashing, authenticated routing, and navigation guards.

Notifications You must be signed in to change notification settings

ginazampino/exercise-vue-auth-jwt-bcrypt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exercise: Authentication & Authorization

Using: Node.js, Express, MariaDB, Vue2, vue-router, Objection/Knex, Axios, cookie-parser, JSON Web Tokens (JWT), and Bcrypt.

Example Functionality

  1. Register a new account
  2. Log in to your account
  3. Update your user profile (form submission)
  4. Log out of your account

Server

REST API

Examples of custom RESTful APIs built with Node.js and Express:

router.post('/register', async (req, res) => {
router.get('/get/user/:id/public', requireSession, async (req, res) => {

ORM

Examples of database interaction performed using Objection with Knex:

async function getUserPets(id) {
async function doRegisterUser(formData) {

Sessions

Examples of managing authentication sessions using JSON Web Tokens (JWT):

function createToken(id) {
async function requireSession(req, res, next) {
async function validateSession(session) {

Password Hashing

Examples of hashing passwords using Bcrypt:

async function createHash(password) {
async function doBcryptCompare(id, password) {
hashedPassword: await createHash(formData.password),

Client

Navigation Guards

Examples of protecting application routes using navigation guards with vue-router:

async function findExistingSession(to, from, next) {
async function guardBehindSession(to, from, next) {
beforeEnter: findExistingSession,
beforeEnter: guardBehindSession
const session = await axios.get('/api/get/cookie').then((result) => { return result; }).catch((error) => { throw error; });

Form Handling

Examples of handling form submission data using Vue2 (Options API) and Axios:

About

An exercise in full-stack account management, password hashing, authenticated routing, and navigation guards.

Topics

Resources

Stars

Watchers

Forks