Skip to content

Add support for updating the user profile#44

Merged
typerandom merged 1 commit intomasterfrom
feature-update-user-profile
Mar 4, 2016
Merged

Add support for updating the user profile#44
typerandom merged 1 commit intomasterfrom
feature-update-user-profile

Conversation

@typerandom
Copy link
Copy Markdown
Contributor

Adds support for updating the user profile with the UserProfileForm component.

Before review

This depends on #43 (add router context support) to be merged. I.e. that PR needs to be merged before we can review this one.

Also, we need to merge this Node SDK PR, because without it any profile validation errors won't be shown.

Note: This PR does not support customData. There's a separate issue for adding support for that.

How to verify

  1. Checkout this branch.
  2. Build it ($ npm run build).
  3. Link it ($ npm link).
  4. Checkout the the React example app.
  5. Link to our React SDK feature branch ($ npm link react-stormpath).
  6. Open up src/pages/ProfilePage.js.
  7. Import the UserProfileForm component from react-stormpath.
  8. Replace the existing form (everything within <form className="form-horizontal" submit={this.onFormSubmit.bind(this)}>) with the new UserProfileForm component (i.e. <UserProfileForm />).
  9. Open up server.js and add the following route to it.
  10. Run the application.
  11. Login as an existing user.
  12. Navigate to /profile (you should automatically have navigated here if you have logged in).
  13. Change the various profile fields and verify that they can be updated.
  14. Read the documentation for the UserProfileForm component.
  15. Implement the custom form according to the docs.
  16. Validate that the form acts and behaves as expected.
  17. Check the console and verify that there are no console errors.

Fixes #18.

@typerandom typerandom force-pushed the feature-update-user-profile branch 2 times, most recently from 1560a2f to bdf91e1 Compare March 4, 2016 06:12
@typerandom typerandom force-pushed the feature-update-user-profile branch from bdf91e1 to 85ec06f Compare March 4, 2016 22:59
@typerandom typerandom force-pushed the feature-update-user-profile branch from 85ec06f to f86573a Compare March 4, 2016 23:10
@robertjd
Copy link
Copy Markdown
Member

robertjd commented Mar 4, 2016

Looks good! Verified with the feature-profile-support branch in the sample project, and the account-save fix branch in the Node SDK.

@typerandom
Copy link
Copy Markdown
Contributor Author

Awesome! I'm going to go ahead and merge this in.

typerandom added a commit that referenced this pull request Mar 4, 2016
Add support for updating the user profile
@typerandom typerandom merged commit 48d18f7 into master Mar 4, 2016
@typerandom typerandom deleted the feature-update-user-profile branch March 4, 2016 23:30
@ghost
Copy link
Copy Markdown

ghost commented Mar 9, 2016

@typerandom I just forked the example app and tested the update profile functionality now that all PR's have been merged but I get the following error when submitting the form:

Unexpected token C in JSON at position 0

@typerandom
Copy link
Copy Markdown
Contributor Author

@davekingsnorth What version of the express-stormpath module are you using? If you are not using the latest, then please try and upgrade to that and let me know:)

@ghost
Copy link
Copy Markdown

ghost commented Mar 9, 2016

@typerandom package.json currently includes version 3.0.0. I changed it to 3.0.1, which is the latest release but no change.

When I update profile it makes an xhr POST request to http://localhost:3000/profile but I receive a 404 response. Any idea what I'm missing?

@typerandom
Copy link
Copy Markdown
Contributor Author

Have you added a handler for POST /me as described in the documentation?

@typerandom
Copy link
Copy Markdown
Contributor Author

Also, by the way. If you are using the branch of this PR, then please instead checkout the master branch. This PR has been merged, so there might have been changes to the master branch related to this.

@typerandom
Copy link
Copy Markdown
Contributor Author

The documentation that you should follow is here: https://github.com/stormpath/stormpath-sdk-react/blob/master/docs/api.md#userprofileform

@typerandom
Copy link
Copy Markdown
Contributor Author

@davekingsnorth I'm sorry. I thought that we had cut a new release with the profile form changes in it. But we haven't. When you run the example app you need to use this branch. It should fix your issues. Let me know if that helped you :) And sorry for the confusion!

@ghost
Copy link
Copy Markdown

ghost commented Mar 9, 2016

@typerandom no worries, appreciate your help. This project will be awesome once I can get profile updates and custom data working.

I have checked out the feature-profile-support branch and added the '/me' endpoint to server.js. It's worth noting that you need to include body-parser, otherwise npm start will fail.

I still get the same issue though:

When I update profile it makes an xhr POST request to http://localhost:3000/profile but I receive a 404 response

@typerandom
Copy link
Copy Markdown
Contributor Author

@davekingsnorth

Thanks for your patience!

And yes, once this is done, it will be really awesome:)

I also think you'll like the new social login support (see #46). If you ever need to use that.

The body-parser should be present (see the package.json). All that should be required is to do a $ npm install, and then that would be installed.

Regarding the /profile request something must be off...

In one of the early versions I used /profile, but this was later changed for consistency to use the /me endpoint. See: https://github.com/stormpath/stormpath-sdk-react/blob/master/src/services/UserService.js#L39

Could it be that you are using an old version? If you run $ git pull --force on the branch, do you see any difference?

Also... After you've checked this out... Did you rebuild it? I.e. $ npm run build? It might be that you are still using an old version, and that you just forgot to rebuild it.

At least, that's a mistake I've done a few times myself :)

@Hanked
Copy link
Copy Markdown

Hanked commented Mar 11, 2016

@typerandom Hi, just tried the following:

  • Cloned the stormpath-sdk-react repo
  • Checked out feature-profile-support branch
  • Added stormpath.yml
  • Exported STORMPATH_CLIENT_APIKEY_ID and STORMPATH_CLIENT_APIKEY_SECRET
  • npm start

And still have these problems:

  • UserProfileForm posting to /profile instead of /me resulting in a 404
  • There is no npm run build command in the stormpath-express-react-examplet -> package.json. Only script is npm start

It feels like the npm react-stormpath v1.0.0 package is the problem.

Any suggestions? Are you able to replicate this issue?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants