loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Can't retrieve the current user from access token.

Open dongmai opened this issue 10 years ago • 7 comments

Bug or feature request

  • [x] Bug
  • [ ] Feature request

Description of feature (or steps to reproduce if bug)

I have a middle-ware that I want to check some logic on the current user, bellow is my code:

screen shot 2016-10-27 at 5 09 36 pm

As I see there is a relation from AccessToken model to User model: screen shot 2016-10-27 at 5 15 55 pm

Expected result

Can get full instance of current user successfully.

Actual result (if bug)

But I got the error : screen shot 2016-10-27 at 5 11 01 pm

Additional information (Node.js version, LoopBack version, etc)

loopback 2.x

dongmai avatar Oct 27 '16 10:10 dongmai

@bajtos Can you please look at this, thanks!

dongmai avatar Oct 28 '16 02:10 dongmai

@dongmai thank you for reporting the bug. Could you please create a small app reproducing the issue? See http://loopback.io/doc/en/contrib/Reporting-issues.html#bug-report for more details.

BTW req.accessToken is already an instance of AccessToken, no need to call findById again.

bajtos avatar Oct 31 '16 17:10 bajtos

@dongmai , have you tried including "user" relation ?

Try this

app.models.AccessToken.findById(req.accessToken, {"include":"user"}, cb);

padelagani avatar Nov 02 '16 04:11 padelagani

@padelagani , It doesn't work. @bajtos Seems it only happens for loopback-connector-mssql

dongmai avatar Nov 05 '16 10:11 dongmai

@dongmai good to know! Could you please create a small app reproducing the problem, as I mentioned in my last comment?

@0candy @loay could you PTAL?

bajtos avatar Nov 09 '16 12:11 bajtos

@dongmai Are you still encountering this issue? If so, could you please provide a sample app for us to reproduce? Thanks!

0candy avatar Mar 15 '17 18:03 0candy

Closing due to inactivity. If you are still running into problems, feel free to leave a comment and I will reopen the issue.

0candy avatar Apr 21 '17 18:04 0candy