auth0 / angular-jwt

Library to help you work with JWTs on AngularJS
MIT License
0 stars 1 forks source link

Minification problems #167

Closed cristianmad closed 4 years ago

cristianmad commented 6 years ago

Hi, I'm currently trying to use angular-jwt in my angular 5 application and I am running into some issues. Everything works well in dev mode, but it fails when switching to prod ("Function expressions are not supported in decorators... Consider changing the function expression into an exported function").

I am initializing the service as following (in the module when defining the providers): JwtModule.forRoot({ config: { tokenGetter: () => { return localStorage.getItem('auth_token'); } } })

According to the documentation, the following approach should be used: jwtOptionsProvider({ tokenGetter: ['store', '$http', function(store, $http) { ... }] });

I'm currently learning Angular, so this may be something obvious for someone with more expertise, but, could someone please give an actual example on how to change my current approach? I tried various things with no success :(

Thanks, Cristian

ShadowManu commented 6 years ago

I'm confused by the question: this is the AngularJS (v1) version of the jwt services, but you're using example code from.. both v1 and v5? I guess you have a ngUpgrade version and you're using both.

In anycase, you probably have an AOT limitations errors and can be easily solved by changing the fat arrow function of the token getter. Instead of doing tokenGetter: () => { ... }, do export function tokenGetterFunction() { ... } ....... tokenGetter: tokenGetterFunction

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️