Skip to content

Add Router context support#43

Merged
timothyej merged 4 commits intomasterfrom
feature-context-support
Mar 4, 2016
Merged

Add Router context support#43
timothyej merged 4 commits intomasterfrom
feature-context-support

Conversation

@typerandom
Copy link
Copy Markdown
Contributor

Adds support for emitting account and authenticated contexts from the Router.

Note

I have deprecated the UserComponent and UserField, since those are no longer needed when we have the account context.

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. Edit the page to look import the account context (as shown in this gist).
  8. Start the app ($ npm start).
  9. Navigate to /login.
  10. Verify that you were navigated to /profile (the page we modified) and that the field values are shown.
  11. Add a console.log(this.context.account); in the render() method of the ProfilePage and verify that the account is written to console.
  12. Login and logout, and verify that the account is undefined when logged out, and an account object when logged in.
  13. Do steps 11-12 but for the authenticated context.
Documentation

See: https://github.com/stormpath/stormpath-sdk-react/blob/feature-context-support/docs/api.md#contexts

Fixes #1.

Comment thread docs/api.md Outdated

#### authenticated (bool)

If you want to know if there's an authenticated account, then include the `authenticated` context.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you mean "If you want to know if the user is authenticated or not, include the authenticated context."?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds better! Thanks!

@timothyej
Copy link
Copy Markdown
Contributor

At step 13, when logged out, printing this.context.authenticated in the header will be printed twice. First as false and then as true.

@typerandom
Copy link
Copy Markdown
Contributor Author

@timothyej All of these things have now been fixed except for the ES2015 semicolon.

@timothyej
Copy link
Copy Markdown
Contributor

Good work! 👍 ⭐

timothyej pushed a commit that referenced this pull request Mar 4, 2016
@timothyej timothyej merged commit 4176568 into master Mar 4, 2016
@timothyej timothyej deleted the feature-context-support branch March 4, 2016 21:41
@typerandom
Copy link
Copy Markdown
Contributor Author

\o/

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.

2 participants