Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "client",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3001",
"devDependencies": {
"eslint-plugin-babel": "^4.1.0",
"eslint-plugin-react": "^6.10.0",
"react-scripts": "0.9.3"
},
"dependencies": {
Expand Down
97 changes: 96 additions & 1 deletion client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,108 @@
import React, { Component } from 'react';
import { BrowserRouter, Route } from 'react-router-dom';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import './App.css';
import SignUpSignIn from './SignUpSignIn';
import TopNavbar from './TopNavbar';
import Secret from './Secret';
import axios from 'axios';

class App extends Component {
constructor(props) {
super(props);

this.state = {
signUpSignInError: '',
authenicated: localStorage.getItem('token') || false
};
}

handleSignUp(credentials) {
const { username, password, confirmPassword } = credentials;

if (!username.trim() || !password.trim() || password.trim() !== confirmPassword.trim()) {
this.setState({
signUpSignInError: 'Must provide all fields'
});
} else {
axios.post('/api/signup', credentials)
.then(resp => {
const { token } = resp.data;
// palces token
localStorage.setItem('token', token);

this.setState({
signUpSignInError: '',
authenicated: token
});
});
}
}

handleSignIn() {
/* const { username, password } = credentials;

if (!username.trim() || !password.trim() ) {
this.setState({
signUpSignInError: 'Must provide all fields'
});
} else {
axios.get('/api/signin', credentials)
.then(resp => {
const { token } = resp.data;
// places token
localStorage.setItem('token', token);

this.setState({
signUpSignInError: '',
authenicated: token
});
});
} */
}

handleSignOut() {
// removes token
localStorage.removeItem('token');

this.setState({
authenicated: false
});
}

renderSignUpSignIn() {
return (
<SignUpSignIn
error={this.state.signUpSignInError}
onSignUp={this.handleSignUp.bind(this)}
/>
);
}

renderApp() {
return (
<div>
<Switch>
<Route exact path="/" render={() => <h1>I am protected!</h1>} />
<Route exact path="/secret" component={Secret} />
<Route render={() => <h1>NOT FOUND!</h1>} />
</Switch>
</div>
);
}

render() {
return (
<BrowserRouter>
<div className="App">
<TopNavbar
showNavItems={this.state.authenicated}
onSignOut={this.handleSignOut.bind(this)}
/>
{this.state.authenicated ? this.renderApp() : this.renderSignUpSignIn()}
</div>
</BrowserRouter>
);
}
}

export default App;
2 changes: 1 addition & 1 deletion client/src/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SignUp extends Component {
username: '',
password: '',
confirmPassword: '',
}
};
}

handleSubmit(event) {
Expand Down
4 changes: 2 additions & 2 deletions client/src/SignUpSignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class SignUpSignIn extends Component {
{this.props.error && this.renderError()}
<Tabs defaultActiveKey={1} id="signup-signin-tabs">
<Tab eventKey={1} title="Sign Up">
<SignUp onSignUp={this.props.onSignUp}/>
<SignUp onSignUp={this.props.onSignUp} />
</Tab>
<Tab eventKey={2} title="Sign In">
Sign In
</Tab>
</Tabs>
</Col>
</Row>
)
);
}
}

Expand Down
7 changes: 4 additions & 3 deletions client/src/TopNavbar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PropTypes } from 'react';
import { Navbar, Nav, NavItem } from 'react-bootstrap';
import { Link } from 'react-router';
import { Link } from 'react-router-dom';

const TopNavbar = (props) => {
return (
Expand All @@ -13,6 +13,7 @@ const TopNavbar = (props) => {
</Navbar.Header>
{
props.showNavItems ?
(
<Navbar.Collapse>
<Nav pullRight>
<NavItem onClick={props.onSignOut}>Sign Out</NavItem>
Expand All @@ -21,11 +22,11 @@ const TopNavbar = (props) => {
<Link to="/secret"><Navbar.Text>Secret</Navbar.Text></Link>
</Nav>
</Navbar.Collapse>
: null
) : null
}
</Navbar>
);
}
};

TopNavbar.propTypes = {
onSignOut: PropTypes.func.isRequired,
Expand Down
83 changes: 81 additions & 2 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ array-unique@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53"

array.prototype.find@^2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/array.prototype.find/-/array.prototype.find-2.0.3.tgz#08c3ec33e32ec4bab362a2958e686ae92f59271d"
dependencies:
define-properties "^1.1.2"
es-abstract "^1.7.0"

arrify@^1.0.0, arrify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
Expand Down Expand Up @@ -1577,6 +1584,13 @@ default-require-extensions@^1.0.0:
dependencies:
strip-bom "^2.0.0"

define-properties@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
dependencies:
foreach "^2.0.5"
object-keys "^1.0.8"

defined@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
Expand Down Expand Up @@ -1751,6 +1765,23 @@ error-ex@^1.2.0:
dependencies:
is-arrayish "^0.2.1"

es-abstract@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
dependencies:
es-to-primitive "^1.1.1"
function-bind "^1.1.0"
is-callable "^1.1.3"
is-regex "^1.0.3"

es-to-primitive@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
dependencies:
is-callable "^1.1.1"
is-date-object "^1.0.1"
is-symbol "^1.0.1"

es5-ext@^0.10.7, es5-ext@^0.10.8, es5-ext@~0.10.11, es5-ext@~0.10.2, es5-ext@~0.10.7:
version "0.10.12"
resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.12.tgz#aa84641d4db76b62abba5e45fd805ecbab140047"
Expand Down Expand Up @@ -1858,6 +1889,10 @@ eslint-module-utils@^1.0.0:
debug "2.2.0"
pkg-dir "^1.0.0"

eslint-plugin-babel@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-4.1.1.tgz#ef285c87039b67beb3bbd227f5b0eed4fb376b87"

eslint-plugin-flowtype@2.21.0:
version "2.21.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.21.0.tgz#a47e85abcdd181d37a336054bd552149ae387d9c"
Expand Down Expand Up @@ -1894,6 +1929,16 @@ eslint-plugin-react@6.4.1:
doctrine "^1.2.2"
jsx-ast-utils "^1.3.1"

eslint-plugin-react@^6.10.0:
version "6.10.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-6.10.3.tgz#c5435beb06774e12c7db2f6abaddcbf900cd3f78"
dependencies:
array.prototype.find "^2.0.1"
doctrine "^1.2.2"
has "^1.0.1"
jsx-ast-utils "^1.3.4"
object.assign "^4.0.4"

eslint@3.8.1:
version "3.8.1"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.8.1.tgz#7d02db44cd5aaf4fa7aa489e1f083baa454342ba"
Expand Down Expand Up @@ -2215,6 +2260,10 @@ for-own@^0.1.4:
dependencies:
for-in "^1.0.1"

foreach@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"

forever-agent@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
Expand Down Expand Up @@ -2273,7 +2322,7 @@ fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10:
mkdirp ">=0.5 0"
rimraf "2"

function-bind@^1.0.2:
function-bind@^1.0.2, function-bind@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"

Expand Down Expand Up @@ -2647,12 +2696,20 @@ is-builtin-module@^1.0.0:
dependencies:
builtin-modules "^1.0.0"

is-callable@^1.1.1, is-callable@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"

is-ci@^1.0.9:
version "1.0.10"
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.0.10.tgz#f739336b2632365061a9d48270cd56ae3369318e"
dependencies:
ci-info "^1.0.0"

is-date-object@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"

is-dotfile@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d"
Expand Down Expand Up @@ -2750,6 +2807,12 @@ is-property@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84"

is-regex@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
dependencies:
has "^1.0.1"

is-resolvable@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62"
Expand All @@ -2766,6 +2829,10 @@ is-svg@^2.0.0:
dependencies:
html-comment-regex "^1.1.0"

is-symbol@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"

is-typedarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
Expand Down Expand Up @@ -3161,7 +3228,7 @@ jsprim@^1.2.2:
json-schema "0.2.3"
verror "1.3.6"

jsx-ast-utils@^1.0.0, jsx-ast-utils@^1.3.1:
jsx-ast-utils@^1.0.0, jsx-ast-utils@^1.3.1, jsx-ast-utils@^1.3.4:
version "1.4.0"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.0.tgz#5afe38868f56bc8cc7aeaef0100ba8c75bd12591"
dependencies:
Expand Down Expand Up @@ -3625,6 +3692,18 @@ object-assign@4.1.1, object-assign@^4.0.1, object-assign@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"

object-keys@^1.0.10, object-keys@^1.0.8:
version "1.0.11"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"

object.assign@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.0.4.tgz#b1c9cc044ef1b9fe63606fc141abbb32e14730cc"
dependencies:
define-properties "^1.1.2"
function-bind "^1.1.0"
object-keys "^1.0.10"

object.omit@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"babel": "^6.23.0",
"babel-cli": "^6.23.0",
"babel-core": "^6.23.1",
"babel-eslint": "^7.1.1",
"babel-istanbul": "^0.12.2",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-builtin-extend": "^1.1.2",
Expand Down
Loading