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, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
import { connect } from 'react-redux'; | |
import { AsyncAboutView } from 'asyncViews'; | |
import { getProfile } from 'actions/access.actions'; | |
import get from 'lodash/get'; | |
import ProfilePlaceholder from 'assets/img/profile_placeholder.png'; | |
import { isValidURL } from 'utils/utils'; | |
import './homeView.scss'; |
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'; | |
export default function AboutView() { | |
return ( | |
<div className="about-view m-3"> | |
<h1>ABOUT PAGE</h1> | |
</div> | |
); | |
} |
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, { Component } from 'react'; | |
import Header from 'components/Header'; | |
import Routes from 'routes'; | |
import LoginFormModal from 'components/LoginForm'; | |
import './App.scss'; | |
export class App extends Component { | |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>AUTH FLOW</title> | |
<meta name="description" content=""> | |
<!-- Mobile-friendly viewport --> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
</head> | |
<body> |
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 ReactDOM from 'react-dom'; | |
import createHistory from 'history/createBrowserHistory'; | |
import { createStore, combineReducers, applyMiddleware } from 'redux'; | |
import { ConnectedRouter, routerReducer, routerMiddleware } from 'react-router-redux'; | |
import { Provider } from 'react-redux'; | |
import createSagaMiddleware from 'redux-saga'; | |
import { composeWithDevTools } from 'redux-devtools-extension/developmentOnly'; | |
import 'bootstrap'; |
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
passport.use( | |
new FacebookStrategy( | |
{ | |
clientID: config.facebookAuth.clientID, | |
clientSecret: config.facebookAuth.clientSecret, | |
callbackURL: config.facebookAuth.callbackURL, | |
profileFields: [ | |
'id', | |
'displayName', | |
'picture.width(200).height(200)', |
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
exports.getLoggedUser = async (ctx) => { | |
if (ctx.isAuthenticated()) { | |
const reqUserId = ctx.req.user.id; | |
let user = null; | |
await getAsync('usersMockDatabase').then((users) => { | |
user = JSON.parse(users).find(currUser => currUser.id === reqUserId); | |
}); | |
if (user) { | |
delete user.password; | |
ctx.response.body = user; |
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
passport.use( | |
new LocalStrategy( | |
{ | |
usernameField: 'email', | |
passwordField: 'password', | |
}, | |
async (email, password, done) => { | |
let user = null; | |
await getAsync('usersMockDatabase').then((users) => { | |
const currUsers = JSON.parse(users); |
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 bcrypt = require('bcrypt'); | |
const passport = require('koa-passport'); | |
const FacebookStrategy = require('passport-facebook').Strategy; | |
const LocalStrategy = require('passport-local').Strategy; | |
const config = require('../serverConfig'); | |
const { db } = require('../server'); | |
const { promisify } = require('util'); | |
const getAsync = promisify(db.get).bind(db); |
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 auth = require('./controllers/auth'); | |
const router = new Router(); | |
router | |
/* Handle Login POST */ | |
.post('/login', ctx => passport.authenticate('local', (err, user) => { | |
if (!user) { | |
ctx.throw(401, err); | |
} else { | |
ctx.body = user; |