Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'hasOwnProperty' of undefined #2212

Closed
1 task done
daniel7912 opened this issue Sep 6, 2016 · 5 comments · Fixed by #2232
Closed
1 task done

Cannot read property 'hasOwnProperty' of undefined #2212

daniel7912 opened this issue Sep 6, 2016 · 5 comments · Fixed by #2232
Labels

Comments

@daniel7912
Copy link

daniel7912 commented Sep 6, 2016

  • 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 4.0.4
Node 5.3.0
npm 3.3.12
Operating System Ubuntu 16.04
Item Answer
Transpiler Babel / TypeScript
Markup HTML / Pug
CSS CSS / LESS / SCSS / Stylus
Router ngRoute / ui-router
Client Tests Jasmine / Mocha
DB MongoDB / SQL
Auth Y

I just ran yo angular-fullstack which worked OK. Then I ran gulp serve, and the page loaded with the following error in the console window:

angular.js:13920 TypeError: Cannot read property 'hasOwnProperty' of undefined at auth.service.ts:138

This is causing the nav bar to display the logout button instead of login too, and I can access the profile page even though I haven't logged in.

@daniel7912
Copy link
Author

Same problem on OS X with node v6.4.0 and npm v3.10.3

@Runaider
Copy link

Runaider commented Sep 6, 2016

Check if argument is defined before calling hasOwnPropertymethod.
var is = user && user.hasOwnProperty('role');should solve this error.

Also getCurrentUser() in auth.service receives an object with an undefinedpromise if user isn't logged in, which isn't handled correctly. A bit of refactoring is required for a better solution to this problem.

@Awk34 Awk34 added the bug label Sep 6, 2016
@yozzd
Copy link

yozzd commented Sep 6, 2016

i run into this problem too..
try change all _User into User in your auth.service

@daniel7912
Copy link
Author

daniel7912 commented Sep 7, 2016

Confirmed working after @yozzd's solution. Thanks!

@andrewt3000
Copy link

yozzd solution does get rid of the console error. not sure if the authentication works though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants