Skip to content
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

implement auth with the Flux based router #70

Closed
frankleng opened this issue Feb 11, 2015 · 24 comments
Closed

implement auth with the Flux based router #70

frankleng opened this issue Feb 11, 2015 · 24 comments

Comments

@frankleng
Copy link

@koistya mind giving an example of how to setup an auth flow with the current setup?
One of the biggest perks of switching to react-router is the out of box support for auth by using nested routes. thanks! ref #21

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@frankleng
Copy link
Author

ping @koistya
mind answering this one?

@koistya
Copy link
Member

koistya commented Feb 17, 2015

@frankleng I'm going to include auth flow example into this kit, hopefully next week.

@frankleng
Copy link
Author

@koistya that'll be great if you have time this week. also with that said, it'll be nice to have a sample for simple redirects.
One of the pain points is debugging routes on the server side. Please let me know if you have any tips.

@cwshevlin
Copy link

@koistya I'm also trying to learn how to implement auth with React, would love an example.

@oliwerhelsen
Copy link

+1

@dqdinh
Copy link

dqdinh commented Apr 8, 2015

The nuclearmail app (https://github.com/ianobermiller/nuclearmail) has a working example of auth using the Gmail REST API

@rosswilson
Copy link

@koistya An example of auth with react-router would be great, have you had any more look into this?

@alesma
Copy link

alesma commented Jun 22, 2015

+1, i spent the whole sunday afternoon trying to get this running, trying to keep my code isomorphic and following the flux architecture without success. I believe this is a deal breaker for many, if anyone already have a working solution to share that would be really handy.

@koistya
Copy link
Member

koistya commented Jun 22, 2015

Here is an example of an alternative routing approach:

Implementing React.js routing from scratch (docs/recipe)

Where you can check authentication in several ways:

router.route('/store/checkout', async () => {
  if (!this.user.isAuthenticated) {
    this.throw(401, 'You must be authenticated.');
  } else {
    const data = await http.get('/api/cart/items');
    this.render(require('./components/Checkout'), data);
  }
});
router.route('/store/checkout', authorize('user'), async () => { ... });
/* where `authorize(..)` is just a regular route handler */
router.route('/store/*', async () => { /* check authentication via `this.user` */ })
router.route('/store/checkout', async () => { /* load data, return component to render */ });

@constantx
Copy link

@koistya the example code has import Router from './core/Router'; but there's no such file. Where can we find it?

@koistya
Copy link
Member

koistya commented Jul 23, 2015

@constantx fixed 'How to implement routing' recipe in 9891699

@constantx
Copy link

@koistya rad, will check it out

@constantx
Copy link

any tip on handling redirect? I'm having a hard time figuring out where to do it (in a store? action? component?)

@koistya
Copy link
Member

koistya commented Jul 24, 2015

@constantx one way is to use Location.navigateTo('/new-path')

@koistya
Copy link
Member

koistya commented Jul 24, 2015

Another way.. is to add this redirect logic to the router, I will try to do it later

@constantx
Copy link

@koistya rad, looking forward to it, thanks for all the hard work!

@lovegroveandy
Copy link

@koistya, awesome work thanks. I agree it would be great to have an auth example route in the kit.

@ACPK
Copy link

ACPK commented Nov 9, 2015

@koistya Would also love an auth example route.

@9mm
Copy link

9mm commented Nov 23, 2015

+1

@DCKT
Copy link

DCKT commented Nov 30, 2015

Could be great ! +1

@gmlnchv
Copy link

gmlnchv commented Dec 1, 2015

@koistya Any progress on this? A working example of a basic auth workflow - token, cookie, user object handling, would be super beneficial for the kit!

@jaredpalmer
Copy link

I use express middleware to ensure authentication for API endpoints. I also use a higher level component to handle component by component permissions. It was a pain to implement this. Would love to see this project move to react router 1.0.

@Bogdaan
Copy link

Bogdaan commented Feb 13, 2016

@constantx @9mm @gmlnchv @lovegroveandy @ACPK
this is not a PR, but i pubish my fork with:

  1. redirects (server and client)
  2. authorization
  3. altjs / flux ( stores, actions, Iso etc.)
    Just for example, and some basic features for personal project "out the box"
    see https://github.com/Bogdaan/react-auth-kit

@langpavel
Copy link
Collaborator

This is really old issue.
Feel free to reopen it if you think it may be useful for someone.

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

No branches or pull requests