this.getUser().get("token"); works for admin, but not for regular user. How can i get the user's token then?
get regular user's token
Collapse
X
-
Tags: None
-
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; },
If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.
Comment