Commit 54e152b1 authored by Tage A. L. K's avatar Tage A. L. K Committed by Tim Neutkens

Minor update to with-apollo-auth (#4426)

Changes
* Update dependencies.
* Remove sending client prop to component on pages.
* Use withApollo correctly on components.
* Use `client.cache.reset()` instead of `prop.client.resetStore()`.

@adamsoffer @timneutkens 
parent 57be892d
......@@ -14,7 +14,7 @@ const CREATE_USER = gql`
}
`
const RegisterBox = (props) => {
const RegisterBox = ({ client }) => {
let name, email, password
return (
......@@ -25,7 +25,7 @@ const RegisterBox = (props) => {
})
// Force a reload of all the current queries now that the user is
// logged in
props.client.resetStore().then(() => {
client.cache.reset().then(() => {
redirect({}, '/')
})
}} onError={(error) => {
......@@ -33,26 +33,26 @@ const RegisterBox = (props) => {
console.log(error)
}}>
{(create, { data, error }) => (
<div>
<form onSubmit={e => {
e.preventDefault()
e.stopPropagation()
<form onSubmit={e => {
e.preventDefault()
e.stopPropagation()
create({ variables: {
create({
variables: {
name: name.value,
email: email.value,
password: password.value
}})
}
})
name.value = email.value = password.value = ''
}}>
{ error && <p>Issue occured while registering :(</p> }
<input name='name' placeholder='Name' ref={node => { name = node }} /><br />
<input name='email' placeholder='Email' ref={node => { email = node }} /><br />
<input name='password' placeholder='Password' ref={node => { password = node }} type='password' /><br />
<button>Register</button>
</form>
</div>
name.value = email.value = password.value = ''
}}>
{error && <p>Issue occured while registering :(</p>}
<input name='name' placeholder='Name' ref={node => { name = node }} /><br />
<input name='email' placeholder='Email' ref={node => { email = node }} /><br />
<input name='password' placeholder='Password' ref={node => { password = node }} type='password' /><br />
<button>Register</button>
</form>
)}
</Mutation>
......
......@@ -12,7 +12,7 @@ const SIGN_IN = gql`
`
// TODO: Find a better name for component.
const SigninBox = (props) => {
const SigninBox = ({ client }) => {
let email, password
return (
......@@ -23,7 +23,7 @@ const SigninBox = (props) => {
})
// Force a reload of all the current queries now that the user is
// logged in
props.client.resetStore().then(() => {
client.cache.reset().then(() => {
redirect({}, '/')
})
}} onError={(error) => {
......@@ -31,24 +31,24 @@ const SigninBox = (props) => {
console.log(error)
}}>
{(signinUser, { data, error }) => (
<div>
<form onSubmit={e => {
e.preventDefault()
e.stopPropagation()
<form onSubmit={e => {
e.preventDefault()
e.stopPropagation()
signinUser({ variables: {
signinUser({
variables: {
email: email.value,
password: password.value
}})
}
})
email.value = password.value = ''
}}>
{ error && <p>No user found with that information.</p> }
<input name='email' placeholder='Email' ref={node => { email = node }} /><br />
<input name='password' placeholder='Password' ref={node => { password = node }} type='password' /><br />
<button>Sign in</button>
</form>
</div>
email.value = password.value = ''
}}>
{error && <p>No user found with that information.</p>}
<input name='email' placeholder='Email' ref={node => { email = node }} /><br />
<input name='password' placeholder='Password' ref={node => { password = node }} type='password' /><br />
<button>Sign in</button>
</form>
)}
</Mutation>
)
......
......@@ -9,15 +9,15 @@
"start": "next start"
},
"dependencies": {
"apollo-boost": "^0.1.4",
"apollo-link-context": "^1.0.7",
"apollo-boost": "^0.1.6",
"apollo-link-context": "^1.0.8",
"cookie": "^0.3.1",
"graphql": "^0.13.2",
"isomorphic-unfetch": "^2.0.0",
"next": "latest",
"prop-types": "^15.6.1",
"react": "^16.2.0",
"react-apollo": "^2.1.1",
"react-dom": "^16.2.0"
"react": "^16.3.2",
"react-apollo": "^2.1.4",
"react-dom": "^16.3.2"
}
}
......@@ -21,12 +21,12 @@ export default class CreateAccount extends React.Component {
render () {
return (
<div>
<React.Fragment>
{/* RegisterBox handles all register logic. */}
<RegisterBox client={this.props.client} />
<RegisterBox />
<hr />
Already have an account? <Link prefetch href='/signin'><a>Sign in</a></Link>
</div>
</React.Fragment>
)
}
};
......@@ -21,12 +21,12 @@ export default class Signin extends React.Component {
render () {
return (
<div>
<React.Fragment>
{/* SigninBox handles all login logic. */}
<SigninBox client={this.props.client} />
<SigninBox />
<hr />
New? <Link prefetch href='/create-account'><a>Create account</a></Link>
</div>
</React.Fragment>
)
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment