compoundjs and railway-passport

486 views
Skip to first unread message

Yaw Joseph Etse

unread,
Dec 24, 2012, 10:31:30 PM12/24/12
to compo...@googlegroups.com
what's the best way to get railway-passport to work with compoundjs? 


i tried changing railway.utils to compound.utils, but that didn't do the trick.

sorry for the Noob-ness

Anatoliy Chakkaev

unread,
Dec 25, 2012, 5:37:09 AM12/25/12
to compo...@googlegroups.com
Railway-passport only for railway. I'm not sure we need compound-passport library for improving passport bad design. It's just wasting time. If someone have free time to support it: feel free to fork from 'compound' branch of 1602/railway-passport (i've pushed some fixes here, but not tested) and publish compound-passport library.


--
The official community of CompoundJS.
 
website: compoundjs.com
source: https://github.com/1602/compound
bug reports: https://github.com/1602/compound/issues?state=open
---
You received this message because you are subscribed to the Google Groups "CompoundJS" group.
To post to this group, send email to compo...@googlegroups.com.
Visit this group at http://groups.google.com/group/compoundjs?hl=en.
 
 



--
Thanks,
Anatoliy Chakkaev

msyea

unread,
Dec 25, 2012, 12:59:19 PM12/25/12
to compo...@googlegroups.com
What's wrong with passport? I've only been using node and compound for about a month now. I've implemented user auth (using passport and a fork of railway-passport) for my app but am still to do access control and account management. Should I scrap passport and use something else? Are there any time tested modules for user management and access control?

Best,
Si

Anatoliy Chakkaev

unread,
Dec 25, 2012, 1:23:17 PM12/25/12
to compo...@googlegroups.com
Passport is fine, if you are using it in correct way. I've tried to improve it's API slightly using railway-passport, but I think this is not needed, and if you like to use passport: just use it directly. Or, better, contact with @jaredhanson and discuss about API improvement in passport directly. It would be much better than support railway-passport or compound-passport.

msyea

unread,
Dec 25, 2012, 1:25:51 PM12/25/12
to compo...@googlegroups.com
Great thanks. Whilst we're on the subject can you recommend some account management and access control modules?

It feels a bit pointless reworking the wheel.

Anatoliy Chakkaev

unread,
Dec 25, 2012, 1:32:18 PM12/25/12
to compo...@googlegroups.com
Sometimes it worth to rework wheel. Especially when you need something simple what could be done in minutes. Every ACL system I've seen feels overengineered, which is really bad. Let's build simple things.

msyea

unread,
Dec 25, 2012, 1:47:28 PM12/25/12
to compo...@googlegroups.com
:-) It just feels painful writing a password reset script! Thanks for the advice.

Yaw Joseph Etse

unread,
Dec 25, 2012, 1:49:22 PM12/25/12
to compo...@googlegroups.com, compo...@googlegroups.com
Agreed, I wish there was a straightforward module for it.

Anatoliy, did you push compound-passport to npm

Sent from my iPhone

Anatoliy Chakkaev

unread,
Dec 25, 2012, 1:50:52 PM12/25/12
to compo...@googlegroups.com
Yes, it hurts first time, and second, and third... But then you have your ideal code, and can give it to community :)

dlochrie

unread,
Dec 26, 2012, 5:00:20 PM12/26/12
to compo...@googlegroups.com
Has anyone got passportjs working with CompoundJS yet? I keep getting stuck with `app` var not being global anymore. Lots of:

var app = compound.app,
                      ^
TypeError: Cannot read property 'app' of undefined

Maybe I'm missing something?

Yaw Etse

unread,
Dec 26, 2012, 5:09:57 PM12/26/12
to compo...@googlegroups.com
currently working on it, but a couple of things to take into account, it'd be pretty hard to work into an existing railway app, I'd start with a clean compound app, and then add compound-passport: https://github.com/yawetse/compound-passport

--
YJE - Programmati.ca

Simon Mayes

unread,
Dec 26, 2012, 5:14:41 PM12/26/12
to compo...@googlegroups.com
I've done it this way:

See 
https://github.com/mayeskennedy/ps-passport

in config/environment.js

        psp = require(app.root + '/lib/ps-passport')
        // init passport
        psp.init(compound);
        // hook up user model
        compound.on('models loaded', function () {
            psp.loadUser(compound.models.User);
        });

--
Regards,
Simon Mayes

Yaw Joseph Etse

unread,
Dec 26, 2012, 6:44:29 PM12/26/12
to compo...@googlegroups.com
I was able to get it up and running, just pushed the code changes out: https://github.com/yawetse/compound-passport

couple of notes.

Environment.js changes
1) process.nextTick wont have model information for User, now using:
compound.on('models loaded', function(){
        User = compound.models.User;
        rwps.loadUser(User);
    });
2) rwps.init(); is no longer needed since it's called in assetcomplier.init 
3) created a new User reference: var User = compound.models.User;

in passport.js
1) app.set is now app.settings
2) now using:         u.findOrCreate = require('./user.js').findOrCreate;

Daniel Lochrie

unread,
Dec 26, 2012, 7:56:50 PM12/26/12
to compo...@googlegroups.com
Hi Yaw,

What strategy did you get it working with? Using your package, the Compound app would not see any routes for Facebook or Google.

Daniel Lochrie

unread,
Dec 26, 2012, 8:02:43 PM12/26/12
to compo...@googlegroups.com
Also, using Simon's code, I was able to nearly get the Google strategy to work, failing only on the callback after authentication. This is with starting from a fresh compound app.

compound init blog
compound generate crud user displayName email googleId facebookId

--either checkout Simon's code, or add Yaw's to the package.json--
npm install -l
compound db migrate (using memory for now)
..set up config/environment.js

- Daniel

Yaw Joseph Etse

unread,
Dec 26, 2012, 8:09:30 PM12/26/12
to compo...@googlegroups.com
Hey Dan, I'm actually still tinkering, sorry my post was a little premature, but I'm getting close

Yaw Joseph Etse

unread,
Dec 26, 2012, 8:19:02 PM12/26/12
to compo...@googlegroups.com
so update, If you move the findOrCreate to user.js (model) then my code works, the issue I was running into was referencing the User model globally is now gone, making it difficult to keep the plugin in the same shape.

I'll test everything out throughly before checking in

Daniel Lochrie

unread,
Dec 26, 2012, 10:12:08 PM12/26/12
to compo...@googlegroups.com
Sounds promising! Passport worked so well with Railway, it would be great to have it with Compound.

Reply all
Reply to author
Forward
0 new messages