Skip to content

fix (makeen-user): make passport.deserializeUser async#10

Open
redbmk wants to merge 1 commit intomakeen-project:masterfrom
redbmk:deserialize-user-async
Open

fix (makeen-user): make passport.deserializeUser async#10
redbmk wants to merge 1 commit intomakeen-project:masterfrom
redbmk:deserialize-user-async

Conversation

@redbmk
Copy link
Copy Markdown

@redbmk redbmk commented Nov 2, 2017

deserializeUser should not try to use
the UserRepository service without waiting for it

deserializeUser should not try to use
the UserRepository service without waiting for it
.findById(objectId(id))
.then(user => cb(null, user), cb);
passport.deserializeUser(async (req, id, cb) => {
const { UserRepository } = await req.app.modules.get('makeen.user');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for that - modules.get('some-module-name') is synchronous and it returns a map of that module's exports

@redbmk
Copy link
Copy Markdown
Author

redbmk commented Nov 2, 2017

That's odd. I was getting this error in my project that's just using the basic makeen.user and this code change fixed it:

TypeError: Cannot read property 'findById' of undefined
    at _passport2.default.deserializeUser (/path/to/packages/core/node_modules/makeen-user/build/libs/passport.js:91:54)

@viczam
Copy link
Copy Markdown
Contributor

viczam commented Nov 3, 2017

That is weird. Are you using this exact module or a modified version of it?

@redbmk
Copy link
Copy Markdown
Author

redbmk commented Nov 3, 2017

Just the vanilla module, v1.8.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants