summaryrefslogtreecommitdiff
path: root/client/components/LoggedOutView.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/LoggedOutView.jsx')
-rw-r--r--client/components/LoggedOutView.jsx26
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()
})