Meteor+React user authentication


#1

What is the best way to manage authentication in a Meteor+React application? I know I can use accounts-ui + accounts-password, but I get Blaze in the middle of this which is not something I’d like to. I’ve found this package named accounts-react from a previous post, but I don’t know how reliable it is.
Any suggestions?


#2

If you are going to build your own. I would suggest using Higher order components to keep track of the user state. This can be a combination of using Meteor’s own withTracker HOC and returning it with Meteor.userId()


#3

Interesting @cloudspider. Can you elaborate a little bit more?


#4

For login you just have to call Meteor.loginWithPassword(values.userName, values.password, callback (err) { });

For checking if the client is a logged user, use Meteor.user() and pass it to component throug container.


#5

Hey @mortsoudain,
So your suggestion is to keep using accounts-password and develop the UI from scratch, right?


#6

Yes thats for sure, but it would be nice to have a react material package that fits on top ofcourse :slightly_smiling_face:


#7

Yep, is not a hard component to build. Just 2 input text, one button to call Meteor.loginWithPassword and a prop attached to Meteor.user() to know if you have to render the login component or authorized content component.