-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Account creation (issue #250) #293
Account creation (issue #250) #293
Conversation
- Style form to match mockup - Fix misimport of user reducer
- Rename log in to sign in to match mockups - Style error messages in sign in form
- Transferring cart to a newly created customer account created an issue where a guest cart could not be made. getCartDetails now checks if a user is signed in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an excellent addition and I'm excited to see it merged. I have a few comments, a couple suggestions, and a couple necessary changes. Please let me know what you think.
It also may require a significant back-merge, but that's just where we are at right now. I'll try to conduct the merge for you--since you have lots of tests, it should be easy to detect regressions.
packages/venia-concept/package.json
Outdated
@@ -7,7 +7,7 @@ | |||
"main": "src/index.js", | |||
"repository": "github:magento-research/pwa-studio", | |||
"bugs": { | |||
"url": "https://github.com/magento-research/pwa-studio/issues" | |||
"url": "https://github.com/magento-research/pwa-studio/issues" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are your editors doing four-space indentation on package.json files? If so, our prettier should be catching this. Whoopsie!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our editors are set to follow the editor config - not sure why it wasn't caught in the prettier. Thanks!
const [dispatch, getState] = args; | ||
const { user } = getState(); | ||
if (user.isSignedIn) { | ||
/////////////////////////////////////////// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good default behavior for now, but could you please add a "TODO: handle logged-in cart retrieval" to this comment? The comment is already helpful, but the string TODO is searchable and helps us find tech debt in the future.
@@ -0,0 +1,121 @@ | |||
import { RestApi } from '@magento/peregrine'; | |||
import BrowserPersistence from 'src/util/simplePersistence.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're using localStorage
in Peregrine and the BrowserPersistence
abstraction here (that later might use Cache or IndexedDB or ServiceWorker or whatever), maybe it's time to move BrowserPersistence
to Peregrine and pull it from there!
Feel like you could do that quickly with this PR, or should we save that for an upcoming PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! We're exporting it the same way as RestAPI is exported from Peregrine. 👍
}; | ||
|
||
function setToken(token) { | ||
localStorage.setItem('signin_token', token); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're using a BrowserPersistence
instance above, maybe use it here.
return this.state.password !== this.state.passwordConfirm; | ||
} | ||
|
||
get disableAccountCreation() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a double take on these method names. hasEmailError
is great, because the wording of the method name says it's a pure method that checks state and returns a boolean. But passwordConfirmError
doesn't follow that convention; seems like it should be called hasPasswordConfirmError
.
Same with disableAccountCreation
. It might be better called isIncompleteOrInvalid
.
<Input | ||
onChange={this.updateUsername} | ||
helpText={'example help text'} | ||
label={'Username or Email'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: If the user has filled out this field and then clicks "Create Account" instead, it should copy this value into the CreateAccount counterpart field.
}); | ||
|
||
const authLink = setContext((_, { headers }) => { | ||
// get the authentication token from local storage if it exists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's another place where you would want to use a BrowserPersistence instance.
|
||
const apolloClient = new ApolloClient(); | ||
const apolloClient = new ApolloClient({ | ||
link: authLink.concat(httpLink), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent job using Apollo Client exactly as intended.
@@ -0,0 +1,73 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this and all other mocks/fixtures into a tests subfolder like fixtures. Add to the Jest exclude pattern if you have to.
"created_at": "2018-09-13T18:26:34.662Z", | ||
"updated_at": "2018-09-13T18:26:34.662Z", | ||
"created_in": "string", | ||
"dob": "1/1/2010", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your customer created their account when they were eight years old. Adorable!
… into account_creation
@zetlen Ok, this pull request has been updated to meet the release/2.0 standards. : ) Also now includes tests (just basic coverage) for user actions/asyncActions. That was quite a merge! |
This PR is a:
[x] New feature
[ ] Enhancement/Optimization
[ ] Refactor
[ ] Bugfix
[ ] Test for existing code
[ ] Documentation
Summary
This pull request is an extension to PR #281 - login feature.
Addresses issue #250
When this pull request is merged, in addition to the changes of #281, it will enable users to create accounts through Magento's REST api.
New components
Additional information
User is automatically logged in after creating an account through getUserDetails() in the root index.js
signin_token expires after some time but stays in local storage, so it's possible to receive a 401 Unauthorized when the root index.js tries to get user details with an expired token. Automatic token refresh should be addressed in the future.
Guest cart is merged into newly created account, but the carts will not show up because getCartDetails still only looks for guest cart ids. Changing this seemed out of scope for this issue so we left it as is.
Style changes for Input component to better match Invision designs.
Automatic email availability check with debounce using Magento isEmailAvailable endpoint.