Closed ghost closed 8 years ago
and is the token sent for other requests you make?
Hi guys.
I have similar problem and it seems to be caused by typo in authenticate.js. Please check line 77 - function getPayload tries to return parsed
but you probably mean _parsed
as defined on line 72.
Current implementation:
{
key: 'getPayload',
value: function getPayload() {
var token = this.storage.get(this.tokenName);
if (token && token.split('.').length === 3) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
try {
var _parsed = JSON.parse(decodeURIComponent(escape(window.atob(base64))));
} catch (error) {
return;
}
return parsed;
}
}
}
@J4ck4l0pe for now just replace it locally and we'll wait for update
@michalru3ch True. We've fixed that one already. A similar fix shouldn't be hard to write for this repository. Want to PR?
You can do it; be my guest. I haven't cloned this library (just using it in my Aurelia project).
No problem, I'll fix it. Thanks for reporting the bug. paul.
fixed in 0.12.2
Thanks for fixing. I also called the getMe()
before the fetchConfig.configure()
. This might also have contributed to the problem.
I am trying to get my user data through the getMe() function, but it doesn't send the header.
config:
var configForDevelopment = { httpInterceptor: true, loginOnSignup: false, baseUrl: '/', loginRedirect: '/', logoutRedirect: '/', signupRedirect: false, loginUrl: '/auth/login', signupUrl: '/auth/register', profileUrl: '/api/v2/users/me', loginRoute: '#/login', signupRoute: '#/register', tokenRoot: false, tokenName: 'token', tokenPrefix: 'aurelia', responseTokenProp: 'access_token', authHeader: 'Authorization', authToken: 'bearer', withCredentials: true, platform: 'browser', storage: 'localStorage' };