Newly installed geddy has a couple of Model issues

23 views
Skip to first unread message

Maria

unread,
Nov 26, 2014, 4:56:55 PM11/26/14
to ged...@googlegroups.com
So I did a fresh global installation of geddy v. 13.0.7 and I encountered a bunch of issues.

So multiple adapters aren't working properly (only the default adapter is being recognized). I did a hotfix by changing the following in geddy/lib/init/model.js line 56:

adapterName = modelItem.adapter && modelItem.adapter.name;

to

adapterName = modelItem.adapter;

Even if that got the multiple adapters working, the relationship mixins aren't working properly. For example,.

given that there was an object Desk with a hasMany relationship with Chair, the following line wouldn't work.

desk.addChair(geddy.model.Chair.create());

Would love some help with this issue. Thanks!

Matthew Eernisse

unread,
Nov 26, 2014, 5:05:18 PM11/26/14
to ged...@googlegroups.com
A few questions so hopefully we can get you unstuck:

- What version of Geddy was used to create the application in question? (Is this a pre-existing app, or a freshly generated app?)

- Are you mixing SQL and noSQL adapters? If you are mixing, I can imagine that there would be problems with associations between the two.

- Could you provide a minimal example of this breakage? Maybe a failing test, or a small public repo with an app that has the problem.

Hopefully we can get you fixed up pretty quickly.



--
The official community discussion group.
website: geddyjs.org, source: https://github.com/mde/geddy, group: https://groups.google.com/d/forum/geddyjs?hl=en
---
You received this message because you are subscribed to the Google Groups "GeddyJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geddyjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Maria

unread,
Nov 26, 2014, 5:48:04 PM11/26/14
to ged...@googlegroups.com
Hi,

I used an earlier version of Geddy for the app. It was originally using the latest version that was out during April 2014 (sorry I can't remember which version it was exactly).

Yes, I was mixing Postgres and MongoDB. However, the associations were only between models using Postgres.

Kindly refer to this repo: http://goo.gl/k78NeZ

The main code is in the main controller, and the app should be run in the development environment.

Thanks again!

Dave Klingler

unread,
Jan 9, 2015, 5:43:29 PM1/9/15
to ged...@googlegroups.com
Hi Geddy-types. I hope the new year is bringing new prosperity to everyone.

Is anyone else using an email login rather than a username? I've been attempting to do this using Geddy/Passport, but lots of stuff seems either missing or obscure enough that I haven't uncovered it.

All of my authentication is local, no oauth or openid, although I'd like to keep the option open for the future and possibly serve oauth some distant future day. Basically, my app needs to do a few things, authentication-wise:

1. I have a password change box, which asks the user to type in the old function and two copies of the new password. It then calls an ajaj function to check that the old pass is valid and if so change the user's password. Perusing through the libs, I didn't see a way to do this off the bat, so I threw up my hands and implemented it without geddy or passport.

2. My login page accepts an email address and password, or an option to create an account. If the email address is new, it goes to an account creation page.

I didn't find passport-local actually installed by default in Geddy, so I guess passport-local's good bits are somewhat well-integrated in auth and login. The Passport guide suggests the following example for email login (http://passportjs.org/guide/configure/):

passport.use(new LocalStrategy({
usernameField:
'email'
,
passwordField:
'passwd'

},

function
(username, password, done) {
//
...

}
));

I installed passport-local and made a couple of minor changes:

this.login = function (req, resp, params) {
passport.use(new LocalStrategy({
usernameField: 'email',
passwordField: 'password'
},
function(username, password, done) {
User.first({ email: username, password: password }, function (err, user) {
done(err, user);
});
}
));
this.respond(params, {
format: 'html'
, layout: 'false'
, template: 'app/views/UserHome/eng/login'
});
};

Which didn't work. Okay, I backed that code out of login and tried it in auth.js instead. No joy. And although adding the new strategy breaks logging in with a username and password, my liberal sprinkling of console.logs weren't getting called inside login. Hum. I threw up my hands and concluded I should write my own email authentication, then remembered that I hadn't yet posted to this handy Geddy group. And here I yam. I'd like to use Geddy/Passport as much as possible. Can anyone point me in a more successful direction? Or point out something that should be painfully obvious?

Also, reading back through the old posts, I also noticed that someone had talked in 2013 about strengthening the auth mechanism with better salting. It looks to me like that was done, er, right? I didn't see it in the change log, so I thought I'd inquire. I've been considering user-specific salts.

Anyway, if you got this far, thanks for reading and thanks in advance for any suggestions!

Dave Klingler



Matthew Eernisse

unread,
Jan 10, 2015, 2:33:56 AM1/10/15
to ged...@googlegroups.com
Dave,

Geddy has baked in auth (including local auth) that you can install via a generator:

`$ geddy gen app foo`
`$ cd foo`
`$ geddy gen auth`

That will install all the needed auth code into your app.

The baked-in auth stuff doesn't bother with passport-local, because it doesn't actually do anything but hand off to a local database lookup. Frankly the code needed to integrate with Passport's crazypants "middleware" API and the multiple exit points (particularly dealing for error handling) is pretty fiddly, and it's not worth jumping through those hoops just for local auth.

You can see how local auth is handled here:

https://github.com/geddy/geddy-passport/blob/master/lib/passport/actions.js#L131

Should be pretty easy to change your required params from using the "username" field to use the "email" field. Either that, or just store the e-mail address as the username.

Hope that helps. Let us know if you need more specifics. :)


Best,

Matthew





Dave Klingler



Dave Klingler

unread,
Jan 10, 2015, 7:25:04 PM1/10/15
to ged...@googlegroups.com
Thanks very much for your reply, Matthew.

I'd gotten burned out yesterday when I gave up and wrote the listserv, and resolved to leave it alone for a day or two. That lasted for about thirty minutes, and then I ended up spending another hazy number of hours reading through Passport docs and code, experimenting and scratching my head.

My app already has auth installed. Your explanation explains why Passport is installing my new strategy without complaining, but never calling it. I tried adding local back into SUPPORTED_STRATEGIES in actions.js, but that caused more code to blow up than I wanted to deal with when I did it.

On Jan 10, 2015, at 12:33 AM, Matthew Eernisse <m...@fleegix.org> wrote:
> The baked-in auth stuff doesn't bother with passport-local, because it doesn't actually do anything but hand off to a local database lookup.

Thanks. I figured I just hadn't spotted where the code had gone. I've been attempting to "do it right", by installing a new local-strategy, so I wouldn't buy myself a bunch of work making my code compatible with future Geddy. It sounds like I shouldn't feel constrained to not hack up what's already been heavily hacked up. :)

> Frankly the code needed to integrate with Passport's crazypants "middleware" API and the multiple exit points (particularly dealing for error handling) is pretty fiddly, and it's not worth jumping through those hoops just for local auth.

Seeing those few lines probably would have saved me several hours of research and head-scratching. It might not be a bad idea to paste it as-is on the Authentication page in the docs. Or as a comment in the code. Or both.

If the middleware's not there, do other strategies install the same way? How much of the Passport docs actually apply to what's in Geddy? Should I be worried about adding some error-handling back in? And what should I not do in order to remain compatible with future Geddy releases?

Thanks again!
Dave

Dave Klingler

unread,
Jan 11, 2015, 1:06:59 AM1/11/15
to ged...@googlegroups.com
Hey, Matthew, I wasn't sure what I could do to help regarding documentation. I know you have your hands full.

I did write a short paragraph to go under "Authentication" just now, but it's not much. I could perhaps write something more elaborate if you let me know what you'd like in it. I can also do some copy editing if you'd like me to help out with typos.

============================
More Elaborate Authentication Methods

Geddy does not implement all of Passport's local strategy middleware, and the LocalStrategy object is not present. To modify local authentication (such as adding email login names), check out action.js in your application's app/helpers/passport directory.
============================

Also, under "Requiring Authentication In Your App" the word "require" is typo'd "reequire".

Also, geddyjs.org puts Passport's settings in secrets.js (under "Configuring Passport"), whereas the default installation puts Passport's settings in environment.js.

I hope some of this is useful! I made a quick run at installing the stock version of Passport under Geddy tonight, just to see whether I could educate myself about what was involved, but I got bogged down in CoffeeScript issues and backburnered it after a while.

Dave


On Jan 10, 2015, at 12:33 AM, Matthew Eernisse <m...@fleegix.org> wrote:

Reply all
Reply to author
Forward
0 new messages