Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:41:41+00:00 2026-06-17T07:41:41+00:00

I have implemented passportJS in my node application. After logging in I get an

  • 0

I have implemented passportJS in my node application. After logging in I get an object which I place in the session. This is the object:

{ loginStatus: 'SUCCESS',
  orgRoles: { '7': 'ALL' },
  orgNames: { '7': 'kianoshp@gmail.com' },
  loginId: 4,
  message: 'Success',
  success: true }

This is the passport configuration (in coffeescript):

passport.serializeUser (user, done) -> 
    console.log 'serializing', user
    done null, user

passport.deserializeUser (user, done) ->
    console.log 'deserializing', user
    done null, user

#passport LocalStrategy
passport.use new LocalStrategy
    usernameField: 'email'
    passwordField: 'password'
    ,
    (username, password, done) ->
        validateUser username, password, done



validateUser = (username, password, done) ->

    console.log 'loginName is --> ' + username + ' password --> ' + password
    options = 
        protocol: API_PROTOCOL
        host: API_HOST
        pathname: '/appservices/login'

    reqURL = url.format options
    requestOptions =
        headers:
            'Content-type': 'application/json; charset=utf-8' 
        body: JSON.stringify 
            loginName: username
            password: password
        method: 'POST'

    request reqURL, requestOptions, (error, response, body) ->
        console.log 'body is --> ' + body
        resObj = JSON.parse body.toString()

        console.log 'loginStatus is --> ' + resObj.loginStatus

        if resObj.loginStatus is 'FAIL' or resObj.loginStatus is 'INVALID_PASSWORD' or resObj.loginStatus is 'LOGIN_NOT_FOUND'
            return done null, false, 
                message: 'We couldn\'t find that email/password, please try again.'
        if resObj.loginStatus is 'ACCOUNT_LOCKED'
            return done null, false, 
                message: 'The user has been locked out due to too many unsuccessful login attempts or the admin has locked the account. Please contact admin or customer support.' 
        if resObj.loginStatus is 'NO_LOGIN_DOMAIN_AVAILABLE'
            return done null, false, 
                message: 'The login attempt is valid but there is no registered domain that the login can access. Please contact admin or customer support.' 
        if resObj.loginStatus isnt 'SUCCESS'
            return done null, false, 
                message: 'The login attempt has failed. If you feel this is an error please try again or contact admin/customer support.' 

        done null, resObj

app.configure ->
    #app.use express.logger()
    app.use express.static(__dirname + '/public')
    app.use express.cookieParser()
    app.use express.bodyParser()
    app.use express.methodOverride()
    app.use express.session
        secret: '###########'
        store: new RedisStore()
        cookie:
            maxAge: 3600000
    app.use flash()
    app.use passport.initialize()
    app.use passport.session()
    app.set 'view engine', 'jade'
    app.set 'views', __dirname + '/views'
    app.use app.router

The output I see:

serializing { loginStatus: 'SUCCESS',
  orgRoles: { '7': 'ALL' },
  orgNames: { '7': 'kianoshp@gmail.com' },
  loginId: 4,
  message: 'Success',
  success: true }
deserializing { loginStatus: 'SUCCESS',
  orgRoles: { '7': 'ALL' },
  orgNames: { '7': 'kianoshp@gmail.com' },
  loginId: 4,
  message: 'Success',
  success: true }

I would like to be able to access that I placed in the session and get values out of it. For example, when I make a GET request, I would like to be able do the following:

app.get '/threatStatus', (res, req) ->
    #I would like to retrieve the loginId for the user that I placed in the session

Any help is greatly appreciated!!

Cheers,

Kianosh

Update:
I was able to get the data I needed by making the following call:

app.get '/threatStatus', (res, req) ->
    console.log req.req.user

Which outputs the following:

{ loginStatus: 'SUCCESS',
  orgRoles: { '7': 'ALL' },
  orgNames: { '7': 'kianoshp@gmail.com' },
  loginId: 4,
  message: 'Success',
  success: true }

Which begs the question, is this correct? Should I have to dive deep into the request object in order to get this data? Is ‘req.req.user’ correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:41:43+00:00Added an answer on June 17, 2026 at 7:41 am

    The user object should be retrieved via req.user.

    You may verify if a user has logged in via req.isAuthenticated() to avoid handling an undefined req.user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a CXF restful webservice . There is some object which does
I have implemented a custom AbstractPreAuthenticatedProcessingFilter which returns a Principal (actually an Object as
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I have implemented the functionality to remove users from the database in my application.
I have implemented Devise confirmable which is working properly. When a user signs up
I have implemented the solution which Cuong suggested here: C# Processing Fixed Width Files
I have implemented quartz scheduler in my application. And its working upto a certain
I have implemented a selection pattern similar to the one described in this post
I have implemented an error style for textboxes using the following code. This sets
i have implemented following method in my application. - (void)accelerometer:(UIAccelerometer *)acel didAccelerate:(UIAcceleration *)aceler {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.