From 33710f8dd4713daa17678d9f78e59a2ee2ef9dc2 Mon Sep 17 00:00:00 2001 From: evpozdniakov Date: Sun, 22 Oct 2017 12:00:53 -0400 Subject: [PATCH 1/8] HT1.2: alter firebase config --- src/config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config.js b/src/config.js index 2782a0b..6ce5a80 100644 --- a/src/config.js +++ b/src/config.js @@ -1,12 +1,12 @@ import firebase from 'firebase' -export const appName = 'advreact-1610' +export const appName = 'advreact-1610-9cb0c' firebase.initializeApp({ - apiKey: "AIzaSyB31xpTtp4Jln_hb2kAbE4PGf6Mi8EgLyA", + apiKey: "AIzaSyBNaOQkLL75ZGoeaNtqbe63wEjjWLzLOPY", authDomain: `${appName}.firebaseapp.com`, databaseURL: `https://${appName}.firebaseio.com`, projectId: appName, storageBucket: "", - messagingSenderId: "397157634637" + messagingSenderId: "266748171955" }) \ No newline at end of file From 17a1433566fb7608ed6a0e7b8f3fd7f2395b05a9 Mon Sep 17 00:00:00 2001 From: evpozdniakov Date: Sun, 22 Oct 2017 12:16:59 -0400 Subject: [PATCH 2/8] HT1.1: complete sign in --- src/components/routes/Auth.js | 6 +++--- src/ducks/auth.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/components/routes/Auth.js b/src/components/routes/Auth.js index a183ff9..ec4898e 100644 --- a/src/components/routes/Auth.js +++ b/src/components/routes/Auth.js @@ -1,7 +1,7 @@ import React, { Component } from 'react' import {Route, NavLink} from 'react-router-dom' import {connect} from 'react-redux' -import {signUp} from '../../ducks/auth' +import {signUp, signIn} from '../../ducks/auth' import SignIn from '../auth/SignIn' import SignUp from '../auth/SignUp' @@ -22,8 +22,8 @@ class AuthPage extends Component { ) } - handleSignIn = (values) => console.log('---', 'sign in', values) + handleSignIn = ({email, password}) => this.props.signIn(email, password) handleSignUp = ({email, password}) => this.props.signUp(email, password) } -export default connect(null, { signUp })(AuthPage) \ No newline at end of file +export default connect(null, { signUp, signIn })(AuthPage) \ No newline at end of file diff --git a/src/ducks/auth.js b/src/ducks/auth.js index 1ab7d1b..5ca5265 100644 --- a/src/ducks/auth.js +++ b/src/ducks/auth.js @@ -13,7 +13,10 @@ export const SIGN_UP_START = `${prefix}/SIGN_UP_START` export const SIGN_UP_SUCCESS = `${prefix}/SIGN_UP_SUCCESS` export const SIGN_UP_ERROR = `${prefix}/SIGN_UP_ERROR` +export const SIGN_IN_START = `${prefix}/SIGN_IN_START` export const SIGN_IN_SUCCESS = `${prefix}/SIGN_IN_SUCCESS` +export const SIGN_IN_ERROR = `${prefix}/SIGN_IN_ERROR` + /** * Reducer @@ -29,6 +32,7 @@ export default function reducer(state = new ReducerRecord(), action) { switch (type) { case SIGN_UP_START: + case SIGN_IN_START: return state.set('loading', true) case SIGN_UP_SUCCESS: @@ -37,6 +41,12 @@ export default function reducer(state = new ReducerRecord(), action) { .set('user', payload.user) .set('loading', false) + case SIGN_UP_ERROR: + case SIGN_IN_ERROR: + return state + .set('error', payload.error) + .set('loading', false) + default: return state } @@ -70,6 +80,24 @@ export function signUp(email, password) { } } +export function signIn(email, password) { + return (dispatch) => { + dispatch({ + type: SIGN_IN_START + }) + + firebase.auth().signInWithEmailAndPassword(email, password) + .then(user => dispatch({ + type: SIGN_IN_SUCCESS, + payload: { user } + })) + .catch(error => dispatch({ + type: SIGN_IN_ERROR, + payload: { error } + })) + } +} + firebase.auth().onAuthStateChanged(user => { if (!user) return From 160a21b0d7f01abeb9b0800d40ec77b501e5914f Mon Sep 17 00:00:00 2001 From: evpozdniakov Date: Sun, 22 Oct 2017 12:31:58 -0400 Subject: [PATCH 3/8] HT1.1: add /admin/people nav link and style it --- public/index.html | 15 +++++++++++++++ src/components/common/Submenu.js | 24 ++++++++++++++++++++++++ src/components/routes/Admin.js | 13 +++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/components/common/Submenu.js diff --git a/public/index.html b/public/index.html index 7bee027..828f249 100644 --- a/public/index.html +++ b/public/index.html @@ -20,6 +20,21 @@ Learn how to configure a non-root public URL by running `npm run build`. --> React App +