Skip to content

Commit

Permalink
user service fix
Browse files Browse the repository at this point in the history
  • Loading branch information
emfmesquita committed Jan 24, 2018
1 parent 9f0744b commit c7e0633
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beyondhelp",
"version": "0.9.1",
"version": "0.9.2",
"private": true,
"dependencies": {
"bootstrap": "^3.3.7",
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Beyond Help",
"version": "0.9.1",
"version": "0.9.2",
"description": "Chrome extension with helpers to https://www.dndbeyond.com/.",
"background": {
"scripts": [
Expand Down
10 changes: 8 additions & 2 deletions src/services/UserService.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ class UserService {
return new Promise((resolve, reject) => {
chrome.cookies.getAll({
domain: ".dndbeyond.com",
name: "User.Username"
name: "User"
}, (cookies) => {
const cookie = cookies && cookies[0] ? cookies[0] : null;
const username = cookie ? cookie.value : null;
const value = cookie ? cookie.value : null;
let username = null;
if (value) {
value.split("&").forEach(token => {
if (token.startsWith("UserName=")) username = token.replace("UserName=", "");
});
}
chrome.runtime.lastError ? reject(chrome.runtime.lastError) : resolve(username);
});
});
Expand Down

0 comments on commit c7e0633

Please sign in to comment.