This file contains 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
const mongoose = require('mongoose'); | |
const passport = require('passport'); | |
const LocalStrategy = require('passport-local'); | |
const Users = mongoose.model('Users'); | |
passport.use(new LocalStrategy({ | |
usernameField: 'user[email]', | |
passwordField: 'user[password]', | |
}, (email, password, done) => { |
This file contains 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
const mongoose = require('mongoose'); | |
const crypto = require('crypto'); | |
const jwt = require('jsonwebtoken'); | |
const { Schema } = mongoose; | |
const UsersSchema = new Schema({ | |
email: String, | |
hash: String, | |
salt: String, |
This file contains 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 -g nodemon |
This file contains 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 -g nodemon |
This file contains 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
const express = require('express'); | |
const path = require('path'); | |
const bodyParser = require('body-parser'); | |
const session = require('express-session'); | |
const cors = require('cors'); | |
const mongoose = require('mongoose'); | |
const errorHandler = require('errorhandler'); | |
//Configure mongoose's promise to global promise | |
mongoose.promise = global.Promise; |
This file contains 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 i -S express body-parser path express-session cors errorhandler mongoose passport passport-local morgan jsonwebtoken express-jwt |
This file contains 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 axios from 'axios'; | |
import React from 'react'; | |
import { connect } from 'react-redux'; | |
class Form extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
title: '', |
This file contains 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
export default (state={articles: []}, action) => { | |
switch(action.type) { | |
case 'HOME_PAGE_LOADED': | |
return { | |
...state, | |
articles: action.data.articles, | |
}; | |
case 'SUBMIT_ARTICLE': | |
return { | |
...state, |
This file contains 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 from 'react'; | |
import axios from 'axios'; | |
import moment from 'moment'; | |
import { connect } from 'react-redux'; | |
import { Form } from '../../components/Article'; | |
class Home extends React.Component { | |
constructor(props) { | |
super(props); |
This file contains 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 from 'react'; | |
import axios from 'axios'; | |
import moment from 'moment'; | |
import { connect } from 'react-redux'; | |
import { Form } from '../../components/Article'; | |
class Home extends React.Component { | |
constructor(props) { | |
super(props); |