From 34691ba687be4adefb12864e49d5c5a357e1a74b Mon Sep 17 00:00:00 2001
From: Jules Laplace <jules@okfoc.us>
Date: Sun, 19 Mar 2017 04:00:24 +0100
Subject: create and update meals

---
 client/components/LoggedOutView.jsx | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

(limited to 'client/components/LoggedOutView.jsx')

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()
       })
-- 
cgit v1.2.3-70-g09d2

