This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // hide email address in pieces to avoid spam | |
| const klingonCloak = (a, b) => { | |
| return a + "@" + b; | |
| } | |
| const birdOfPrey = klingonCloak("info", "listservenyc.com"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // auth.js (authentication route file) | |
| const bcrypt = require('bcrypt'); | |
| router.post('/login', (req, res, next) => { | |
| const { username, password } = req.body; | |
| User.findOne({ | |
| where: { | |
| username: req.body.username | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // User.js (model file) | |
| const conn = require('./conn'); | |
| const bcrypt = require('bcrypt'); | |
| const saltRounds = 12; | |
| const User = conn.define('user', { | |
| id: { | |
| type: conn.Sequelize.UUID, | |
| defaultValue: conn.Sequelize.UUIDV4, | |
| primaryKey: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // route.js (route file) | |
| const { User } = require('../db'); | |
| router.post('/user/create', (req, res, next) => { | |
| User.create(req.body) | |
| .then(officer => res.status(201).send(officer)) | |
| .catch(error => next(error)) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // route.js | |
| const { User } = require('../db'); | |
| router.post('/user/create', (req, res, next) => { | |
| bcrypt.hash(req.body.password, saltRounds, (error, hash) => { | |
| User.create({ | |
| firstName: req.body.firstName, | |
| lastName: req.body.lastName, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // route.js | |
| const bcrypt = require('bcrypt'); | |
| const saltRounds = 12; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| npm install bcrypt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component, Fragment } from 'react' | |
| import { connect } from 'react-redux'; | |
| import { Link } from 'react-router-dom'; | |
| // sample data structure | |
| // const users = [ | |
| // { firstname: 'Jean-Luc', lastname: 'Picard', username: 'jpicard' }, | |
| // { firstname: 'William T.', lastname: 'Riker', username: 'jpicard' }, | |
| // { firstname: 'Data', lastname: 'Data', username: 'jpicard' }, | |
| // ] |