diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-03-19 04:00:24 +0100 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-03-19 04:00:24 +0100 |
| commit | 34691ba687be4adefb12864e49d5c5a357e1a74b (patch) | |
| tree | 70def60ada8d511d37ef0da49bdc8698d5672b74 /client/components/LoggedOutView.jsx | |
| parent | c548b3bd3f0de1a1a74606d60ef9fdd323792918 (diff) | |
create and update meals
Diffstat (limited to 'client/components/LoggedOutView.jsx')
| -rw-r--r-- | client/components/LoggedOutView.jsx | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/client/components/LoggedOutView.jsx b/client/components/LoggedOutView.jsx index e058455..f217143 100644 --- a/client/components/LoggedOutView.jsx +++ b/client/components/LoggedOutView.jsx @@ -1,5 +1,6 @@ import React from 'react' import ModalDialog from './ModalDialog.jsx' +import client from '../client' export default class LoggedOutView extends React.Component { constructor() { @@ -27,11 +28,9 @@ export default class LoggedOutView extends React.Component { onLoginClick={this.showLogin} onSignupClick={this.showSignup} /> <LoginForm - client={this.props.client} visible={loginVisible} onClose={this.closeModal} /> <SignupForm - client={this.props.client} visible={signupVisible} onClose={this.closeModal} /> </div> @@ -76,15 +75,13 @@ class LoginForm extends React.Component { } handleSubmit(event) { event.preventDefault() - this.props.client.authenticate({ + client.authenticate({ type: 'local', email: this.state.email, password: this.state.password, }).then(res => { console.log('Authenticated!', res); - // this.props.client.set('user', res.data) - // something in this library is hardcoded accessToken - // return this.props.client.passport.setJWT(res.token) + window.location.reload() }).catch(error => { console.error('Error authenticating!', error); this.setState({ @@ -138,23 +135,18 @@ class SignupForm extends React.Component { } handleSubmit(event) { event.preventDefault() - const usersService = this.props.client.service('users') + const usersService = client.service('users') usersService.create(this.state).then(result => { - return this.props.client.authenticate({ + return client.authenticate({ strategy: 'local', email: this.state.email, password: this.state.password, }) - }) - .then(res => { - this.props.client.set('user', res.data) - this.props.client.set('token', res.accessToken) - return client.passport.verifyJWT(res.accessToken) - }) - .then(payload => { - console.log(payload) + }).then(res => { + console.log('Authenticated!', res) + window.location.reload() }).catch(error => { - console.error(error) + console.error('Error authenticating!', error) this.setState({ error: error.toString() }) |
