this.getUser().get("token"); works for admin, but not for regular user. How can i get the user's token then?
Announcement
Collapse
No announcement yet.
get regular user's token
Collapse
X
-
Hi,
not know if it's the best way, but this do the trick :
so for admin and for regular user.
PHP Code:
getMyToken() {
if (this.getUser().isAdmin()) {
return this.getUser().get('token');
}else{
let cookies = document.cookie.split(";");
let cookie = [];
for(let i = 0; i < cookies.length; i++) {
cookie = cookies[i].split("=");
if('auth-token' == cookie[0].trim()) {
return decodeURIComponent(cookie[1]);
}
}
}
return null;
},
- Likes 1
Comment