Title: Logged in user will not be detected if refreshing in AuthGuarded route · Issue #2774 · angular-fullstack/generator-angular-fullstack · GitHub
Open Graph Title: Logged in user will not be detected if refreshing in AuthGuarded route · Issue #2774 · angular-fullstack/generator-angular-fullstack
X Title: Logged in user will not be detected if refreshing in AuthGuarded route · Issue #2774 · angular-fullstack/generator-angular-fullstack
Description: I understand that GitHub issues are not for tech support, but for questions specific to this generator, bug reports, and feature requests. Item Version generator-angular-fullstack 5.0.0 rc 4 + fix PRs Node 8.10.0 npm 5.7.1 Operating Syst...
Open Graph Description: I understand that GitHub issues are not for tech support, but for questions specific to this generator, bug reports, and feature requests. Item Version generator-angular-fullstack 5.0.0 rc 4 + fix ...
X Description: I understand that GitHub issues are not for tech support, but for questions specific to this generator, bug reports, and feature requests. Item Version generator-angular-fullstack 5.0.0 rc 4 + fix ...
Opengraph URL: https://github.com/angular-fullstack/generator-angular-fullstack/issues/2774
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Logged in user will not be detected if refreshing in AuthGuarded route","articleBody":" - [x] I understand that GitHub issues are not for tech support, but for questions specific to this generator, bug reports, and feature requests.\r\n\r\nItem | Version\r\n----- | -----\r\ngenerator-angular-fullstack | 5.0.0 rc 4 + fix PRs\r\nNode | 8.10.0\r\nnpm | 5.7.1\r\nOperating System | Windows 10\r\n\r\nItem | Answer\r\n----- | -----\r\nTranspiler | TypeScript\r\nMarkup | HTML\r\nCSS | SCSS\r\nRouter | ngRoute\r\nClient Tests | Mocha\r\nDB | SQL\r\nAuth | Y \r\n\r\nA user that has sucesfully logged on will not be detected as logged in if the site is refreshed inside an AuthGuarded route.\r\n\r\nSteps to reproduce bug:\r\n1. Use generator\r\n2. Log in as admin user\r\n3. Click on Admin tab on nav bar\r\n4. Use browser refresh\r\n\r\nCause:\r\nRouter is evaluating the CanActivate function before the constructor has retrevied the user from the Token\r\n\r\nAuthGuard triggered\r\n```\r\ncanActivate() {\r\n\treturn this.authService.isLoggedIn();\r\n}\r\n```\r\n```\r\nisLoggedIn(callback?) {\r\n\tlet is = !!this.currentUser._id;\r\n\t//at this time is continues to be undefined\r\n\tsafeCb(callback)(is);\r\n\treturn Promise.resolve(is);\r\n}\r\n```\r\nAuthGuard Cancels Navigation\r\n\r\nThis part of the constructor finishes running and get the user too late.\r\n```\r\nif(localStorage.getItem('id_token')) {\r\n\tthis.UserService.get().toPromise()\r\n\t\t.then((user: User) => {\r\n\t\t\tthis.currentUser = user;\r\n\t\t})\r\n\t\t.catch(err => {\r\n\t\t\tconsole.log(err);\r\n\r\n\t\t\tlocalStorage.removeItem('id_token');\r\n\t\t});\r\n}\r\n```\r\nClick on another authguarded route after this will work. Bug only occurs while refreshing.","author":{"url":"https://github.com/blindstuff","@type":"Person","name":"blindstuff"},"datePublished":"2018-11-10T04:14:33Z","url":"https://github.com/angular-fullstack/generator-angular-fullstack/issues/2774"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:914e4933-f889-9144-0a60-3f23dd7f5406 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 957E:18020:6D80B5:92307E:6B00371B |
| html-safe-nonce | fd9d23abc2b3209735fc4f3397e72f5a8d0ac140f123376d12e7919ccd3cf2a6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTdFOjE4MDIwOjZEODBCNTo5MjMwN0U6NkIwMDM3MUIiLCJ2aXNpdG9yX2lkIjoiNTk5MjcxODI3OTE4ODI5MzM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4d57948a51325c6864ffcaffa2e79b786f091d5b5e7029dda4a0c6baaa4e0d52 |
| hovercard-subject-tag | issue:379388506 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular-fullstack/generator-angular-fullstack/2774/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b84a0a4fd901ff6e7970f7719e190c6c7470c39d522bab0833a8e75415fa212e/angular-fullstack/generator-angular-fullstack/issues/2774 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b84a0a4fd901ff6e7970f7719e190c6c7470c39d522bab0833a8e75415fa212e/angular-fullstack/generator-angular-fullstack/issues/2774 |
| og:image:alt | I understand that GitHub issues are not for tech support, but for questions specific to this generator, bug reports, and feature requests. Item Version generator-angular-fullstack 5.0.0 rc 4 + fix ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | blindstuff |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular-fullstack/generator-angular-fullstack git https://github.com/angular-fullstack/generator-angular-fullstack.git |
| octolytics-dimension-user_id | 12663106 |
| octolytics-dimension-user_login | angular-fullstack |
| octolytics-dimension-repository_id | 13911118 |
| octolytics-dimension-repository_nwo | angular-fullstack/generator-angular-fullstack |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13911118 |
| octolytics-dimension-repository_network_root_nwo | angular-fullstack/generator-angular-fullstack |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width