decareano / node-sequelize-postgresql

MIT License
0 stars 0 forks source link

Error on line 16? #9

Open jedireza opened 7 years ago

jedireza commented 7 years ago

Continued from https://github.com/nodeschool/sanfrancisco/issues/197#issuecomment-285121927

The error is in app.js Line 16. I am using the wrong model or the model is not properly setup in the app. I was following Jared Hanson Passport document.

This doesn't give much information to help with (like the error you're seeing). Though I did notice on line 16 that you're calling public.users.findById(...). But public isn't a variable in scope from what I can tell.

📟 @trott @tlhunter

Trott commented 7 years ago

Yeah, I would expect that to give a ReferenceError saying that public is not defined.

decareano commented 7 years ago

@trott @tlhunter @jedireza. I cleaned the app.js file a bit just so you can see the error Rich was talking about: User is not defined undefined ReferenceError: User is not defined

Lines 15-49 in app.js is Postgresql code (commented out) to execute query. I have a table called users in database marcelo. In it I have username = 'marcelo' and password = 'test' as values for passport to authenticate. It also has an ID column which serves as PK.

Lines 51-76 in app.js is active code from the documentation by Jared Hanson (using mongoose and mongo db) I assume.

https://github.com/decareano/node-sequelize-postgresql/tree/passport_WIP

Trott commented 7 years ago

Please don't omit the stacktraces for any errors you want someone to help you with.

decareano commented 7 years ago

Update. With Moose help (Thanks Moose) I was able to get pass Reference Error: User is not defined. We run out of time but now code is failing at the point of executing the strategy. It's NOT going through the sequence of ifs statements needed to authenticate the user. Branch link below. Rich, how do I enable the stacktraces? https://github.com/decareano/node-sequelize-postgresql @Shinobi881 @jedireza @Trott @tlhunter

Trott commented 7 years ago

@decareano Perhaps I'm making an incorrect assumption. I assumed that if you were getting ReferenceError: User is not defined, that it was part of a larger stacktrace that would look something like this:

ReferenceError: User is not defined
    at eval (eval at <anonymous> (/Users/user_redacted/src/appname_redacted/service/svcname-redacted.js:1:1), <anonymous>:44:21)
    at eval (eval at <anonymous> (/Users/user_redacted/src/appname_redacted/service/svcname-redacted.js:1:1), <anonymous>:86:5)
    at /Users/user_redacted/src/appname_redacted/service/svcname-redacted.js:1:1

However, it now occurs to me that you may be seeing this error in a log file that doesn't include all that additional information or something like that. However, if you are seeing a bunch of additional lines like that above, those are really helpful in troubleshooting.

Trott commented 7 years ago

(Regardless, glad you made some progress! 🎉 )