node.js: transforming and returning passport.js profile upon authentication onto request object gives Promise { <pending> } -


so i'm authenticating passport.js this:

passport.use(    new googlestrategy(      config.google,      async (accesstoken, refreshtoken, profile, done) => {        done(null, transformgoog(profile._json, accesstoken, refreshtoken));      }    )  );

this transformgoog function

async function transformgoog(profile, token, refresh) {   try {    //querying database here   if (data) {   return {     uniqueid: data.uniqueid,     provider: data.provider   };  } else {    //constructing object save database here    let newuser = new user(obj);    await newuser.save();    return {     uniqueid: `google:${profile.id}`,     provider: "google",    };  }  } catch (e) {  console.error(e);  }    } 

here's console.log request object

router.get(   "/auth/google/callback",   passport.authenticate("google", { failureredirect: "/auth/google" }),   ctx => console.log(ctx.req.user) ); 

and promise { <pending> }. i'm unsure on means or how fix it.

solved: modified await request object so

router.get( "/auth/google/callback", passport.authenticate("google", { failureredirect: "/auth/google" }), async ctx => console.log(await ctx.req.user) );


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -