FAQ
Just started looking as some node.js code that I inherited. It uses
passport and express and I get the following error when I try to load the
home page of the site:

Tue May 21 2013 22:12:38 GMT-0700 (PDT) 1
GET / controller: main action: index
perform protect from forgery
<<< protect from forgery [0 ms]
perform loadUser
/Users/toddysm/Development/Projects/iddioodev/app/controllers/application_controller.js:19
if (session.passport.user) {
            ^
TypeError: Cannot read property 'passport' of undefined
     at Object.loadUser
(/Users/toddysm/Development/Projects/iddioodev/app/controllers/application_controller.js:19:13)
     at Object.<anonymous>
(/Users/toddysm/Development/Projects/iddioodev/node_modules/railway/lib/controller.js:377:20)
     at
/Users/toddysm/Development/Projects/iddioodev/node_modules/railway/lib/controller.js:354:24
     at process._tickCallback (node.js:415:13)

It seems the session object is not created but I have no idea why.
Shouldn't this be created automatically when the user accesses the site?

Thanks for the help!
Toddy

--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Mscdex at May 22, 2013 at 12:25 pm

    On May 22, 1:19 am, Toddy Mladenov wrote:
    It seems the session object is not created but I have no idea why.
    Shouldn't this be created automatically when the user accesses the site?
    Are you sure that the session middleware is being loaded before the
    code in question?

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Toddy Mladenov at May 23, 2013 at 3:35 pm
    I am not. Can you give me some hints what this session middleware should be?
    On Wednesday, May 22, 2013 5:25:54 AM UTC-7, mscdex wrote:
    On May 22, 1:19 am, Toddy Mladenov wrote:
    It seems the session object is not created but I have no idea why.
    Shouldn't this be created automatically when the user accesses the site?
    Are you sure that the session middleware is being loaded before the
    code in question?
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mscdex at May 23, 2013 at 4:03 pm

    On May 23, 11:35 am, Toddy Mladenov wrote:
    I am not. Can you give me some hints what this session middleware should be?
    Just look at the order of your `app.use()` calls.

    According to passport's site, the order should be something like this:

    app.configure(function() {
       app.use(express.static('public'));
       app.use(express.cookieParser()); // first
       app.use(express.bodyParser());
       app.use(express.session({ secret: 'keyboard cat' })); // second
       app.use(passport.initialize()); // third
       app.use(passport.session()); // fourth
       app.use(app.router); // fifth
    });

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Toddy Mladenov at May 27, 2013 at 4:49 pm
    Well, all of those are don but the session object is still undefined after
    I login with Twitter (Twitter strategy is used). I don't see any cookie
    express the express.sid one that is set for the site. Shouldn't there be
    passport cookie too? Also, is the session object global and accessible from
    everywhere?

    Thanks
    On Tuesday, May 21, 2013 10:19:29 PM UTC-7, Toddy Mladenov wrote:

    Just started looking as some node.js code that I inherited. It uses
    passport and express and I get the following error when I try to load the
    home page of the site:

    Tue May 21 2013 22:12:38 GMT-0700 (PDT) 1
    GET / controller: main action: index
    perform protect from forgery
    <<< protect from forgery [0 ms]
    perform loadUser

    /Users/toddysm/Development/Projects/iddioodev/app/controllers/application_controller.js:19
    if (session.passport.user) {
    ^
    TypeError: Cannot read property 'passport' of undefined
    at Object.loadUser
    (/Users/toddysm/Development/Projects/iddioodev/app/controllers/application_controller.js:19:13)
    at Object.<anonymous>
    (/Users/toddysm/Development/Projects/iddioodev/node_modules/railway/lib/controller.js:377:20)
    at
    /Users/toddysm/Development/Projects/iddioodev/node_modules/railway/lib/controller.js:354:24
    at process._tickCallback (node.js:415:13)

    It seems the session object is not created but I have no idea why.
    Shouldn't this be created automatically when the user accesses the site?

    Thanks for the help!
    Toddy
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Toddy Mladenov at May 27, 2013 at 5:07 pm
    Well, all of those are done but the session object is still undefined after
    I login with Twitter (Twitter strategy is used). I don't see any cookie
    except the express.sid one that is set for the site. Shouldn't there be
    passport cookie too? Also, is the session object global and accessible from
    everywhere?

    Thanks
    On Tuesday, May 21, 2013 10:19:29 PM UTC-7, Toddy Mladenov wrote:

    Just started looking as some node.js code that I inherited. It uses
    passport and express and I get the following error when I try to load the
    home page of the site:

    Tue May 21 2013 22:12:38 GMT-0700 (PDT) 1
    GET / controller: main action: index
    perform protect from forgery
    <<< protect from forgery [0 ms]
    perform loadUser

    /Users/toddysm/Development/Projects/iddioodev/app/controllers/application_controller.js:19
    if (session.passport.user) {
    ^
    TypeError: Cannot read property 'passport' of undefined
    at Object.loadUser
    (/Users/toddysm/Development/Projects/iddioodev/app/controllers/application_controller.js:19:13)
    at Object.<anonymous>
    (/Users/toddysm/Development/Projects/iddioodev/node_modules/railway/lib/controller.js:377:20)
    at
    /Users/toddysm/Development/Projects/iddioodev/node_modules/railway/lib/controller.js:354:24
    at process._tickCallback (node.js:415:13)

    It seems the session object is not created but I have no idea why.
    Shouldn't this be created automatically when the user accesses the site?

    Thanks for the help!
    Toddy
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedMay 22, '13 at 11:07a
activeMay 27, '13 at 5:07p
posts6
users2
websitenodejs.org
irc#node.js

2 users in discussion

Toddy Mladenov: 4 posts Mscdex: 2 posts

People

Translate

site design / logo © 2021 Grokbase