diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-05-16 10:54:08 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-05-16 10:54:08 -0400 |
| commit | 802b65cfd634305f62d88cb57c54f8c053701d27 (patch) | |
| tree | 12a06778d21a8b14bade3ccc8c9dd75f59f97e4a /frontend/components | |
| parent | 3f9b14e3c1d7f47d9b3e48b94b3b5bf2c722205e (diff) | |
SSR Auth WIP
Diffstat (limited to 'frontend/components')
| -rw-r--r-- | frontend/components/Nav.js | 10 | ||||
| -rw-r--r-- | frontend/components/Signin.js | 2 | ||||
| -rw-r--r-- | frontend/components/Signup.js | 1 |
3 files changed, 9 insertions, 4 deletions
diff --git a/frontend/components/Nav.js b/frontend/components/Nav.js index a90568c..4bbce2d 100644 --- a/frontend/components/Nav.js +++ b/frontend/components/Nav.js @@ -4,14 +4,18 @@ import { Query, ApolloConsumer } from 'react-apollo'; import { CURRENT_USER_QUERY } from '../queries/queries.graphql'; import CartCount from './CartCount'; import Signout from './Signout'; - +import Dump from './Dump'; import NavStyles from './styles/NavStyles'; class Nav extends React.Component { render() { + // below we set the fetchPolicy to network only so it forces re-fetch on the server return ( - <Query query={CURRENT_USER_QUERY}> - {({ data: { me } }) => ( + <Query + query={CURRENT_USER_QUERY} + fetchPolicy={process.browser ? 'cache-first' : 'network-only'} + > + {({ data: { me }, loading, error }) => ( <NavStyles data-test="nav"> <Link href="/items"> <a>Shop</a> diff --git a/frontend/components/Signin.js b/frontend/components/Signin.js index 7a4db8c..9e25cf1 100644 --- a/frontend/components/Signin.js +++ b/frontend/components/Signin.js @@ -28,7 +28,7 @@ class Signin extends Component { {client => ( <Mutation mutation={SIGNIN_MUTATION} variables={this.state}> {(signin, { loading, error }) => ( - <Form onSubmit={e => this.loginUser(e, signin, client)}> + <Form method="post" onSubmit={e => this.loginUser(e, signin, client)}> <Error error={error} /> <fieldset disabled={loading} aria-busy={loading}> <label htmlFor="email"> diff --git a/frontend/components/Signup.js b/frontend/components/Signup.js index 22a729f..ef622ed 100644 --- a/frontend/components/Signup.js +++ b/frontend/components/Signup.js @@ -23,6 +23,7 @@ class Signup extends Component { <Mutation mutation={SIGNUP_MUTATION} variables={this.state}> {(signup, { loading, error }) => ( <Form + method="post" onSubmit={async e => { e.preventDefault(); const res = await signup(); |
