{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-next/issues/1275","repository_url":"https://api.github.com/repos/strongloop/loopback-next","labels_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1275/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1275/comments","events_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1275/events","html_url":"https://github.com/strongloop/loopback-next/issues/1275","id":317191086,"number":1275,"title":"Getting the authentication instructions to work","user":{"login":"joeytwiddle","id":911799,"avatar_url":"https://avatars3.githubusercontent.com/u/911799?v=4","gravatar_id":"","url":"https://api.github.com/users/joeytwiddle","html_url":"https://github.com/joeytwiddle","followers_url":"https://api.github.com/users/joeytwiddle/followers","following_url":"https://api.github.com/users/joeytwiddle/following{/other_user}","gists_url":"https://api.github.com/users/joeytwiddle/gists{/gist_id}","starred_url":"https://api.github.com/users/joeytwiddle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeytwiddle/subscriptions","organizations_url":"https://api.github.com/users/joeytwiddle/orgs","repos_url":"https://api.github.com/users/joeytwiddle/repos","events_url":"https://api.github.com/users/joeytwiddle/events{/privacy}","received_events_url":"https://api.github.com/users/joeytwiddle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-24T11:52:22Z","updated_at":"2018-04-25T14:35:30Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I have started from a generated server and tried following the [authentication instructions](https://github.com/strongloop/loopback-next/tree/master/packages/authentication) but when I introduce this injection to my controller:\r\n```js\r\n@inject(AuthenticationBindings.CURRENT_USER) private user: UserProfile,\r\n```\r\n\r\nI get the following error: (***now fixed***)\r\n```\r\nError while serving route '/user': Error: The key authentication.currentUser was not bound to any value.\r\n    at TradingServerApplication.getBinding (.../node_modules/@loopback/context/src/context.ts:400:11)\r\n    at RestServer.getBinding (.../node_modules/@loopback/context/src/context.ts:396:27)\r\n```\r\n\r\n**Did I perhaps miss something from the setup?**\r\n\r\nWhere is the CURRENT_USER provider supposed to get added to the registry?\r\n\r\n----\r\nAdditional info:\r\n\r\nTypeScript had been complaining about the type of `AuthenticationBindings.CURRENT_USER` not being a string, but I fixed that by updating all the `*loopback*` packages in my project today.\r\n\r\nIf I remove the `@inject()` but keep `@authenticate('BasicStrategy')` in my controller, then this line gets reached:\r\n```js\r\n      return new BasicStrategy(this.verify);\r\n```\r\nbut the `verify()` function just below it never gets called. Instead, the route handler reports:\r\n```\r\nUnauthorizedError: Basic realm=\"Users\"\r\n```\r\n\r\n**Is there an example server with working authentication anywhere?**\r\n\r\nIf not I will try to reproduce the problem in a tiny server project tomorrow. Cheers!"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-next/issues/comments/384309615","html_url":"https://github.com/strongloop/loopback-next/issues/1275#issuecomment-384309615","issue_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1275","id":384309615,"user":{"login":"shimks","id":18518689,"avatar_url":"https://avatars2.githubusercontent.com/u/18518689?v=4","gravatar_id":"","url":"https://api.github.com/users/shimks","html_url":"https://github.com/shimks","followers_url":"https://api.github.com/users/shimks/followers","following_url":"https://api.github.com/users/shimks/following{/other_user}","gists_url":"https://api.github.com/users/shimks/gists{/gist_id}","starred_url":"https://api.github.com/users/shimks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shimks/subscriptions","organizations_url":"https://api.github.com/users/shimks/orgs","repos_url":"https://api.github.com/users/shimks/repos","events_url":"https://api.github.com/users/shimks/events{/privacy}","received_events_url":"https://api.github.com/users/shimks/received_events","type":"User","site_admin":false},"created_at":"2018-04-25T14:35:30Z","updated_at":"2018-04-25T14:35:30Z","author_association":"CONTRIBUTOR","body":"Taking a quick look, it seems like `AuthenticationBindings.CURRENT_USER` isn't bound to the app context. Have you made sure to register the `AuthenticationComponent` to the app context?"}}
{"actor":{"display_login":"shimks"}}