Skip to content

Commit

Permalink
try to fix problem on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
makos135 committed Oct 10, 2023
1 parent 36ab0ca commit 70bf726
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ To access data

```WebApp.CloudStorage.getItem('token', (err, token) => { });```

!!! FOR SOME REASON ON MACOS I DO NOT RECEIVE CALLBACK HERE

getItem method has callback function as second parameter where we can access data (or got error)

When user open application first time application sends information about user to backend, save user information in database and return token for next user authentication. This token is stored in `WebApp.CloudStorage` for latter usage. (This is not the best solution of authentication as token is not refreshed, this should be changed letter).
Expand Down
31 changes: 21 additions & 10 deletions src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,31 @@ const fetchToken = () => {
tryToLinkToRoom();
resolve();
}
WebApp.CloudStorage.getItem('token', (err, token) => {
if (!err && token) {
TOKEN = token;

if(WebApp.platform === 'macos') {
initUser().then(json => {
TOKEN = json.token;
WebApp.CloudStorage.setItem('token', TOKEN);
tryToLinkToRoom();
resolve();
} else {
initUser().then(json => {
TOKEN = json.token;
WebApp.CloudStorage.setItem('token', TOKEN);
}).catch(reject);
}
else {
WebApp.CloudStorage.getItem('token', (err, token) => {
if (!err && token) {
TOKEN = token;
tryToLinkToRoom();
resolve();
}).catch(reject);
}
});
} else {
initUser().then(json => {
TOKEN = json.token;
WebApp.CloudStorage.setItem('token', TOKEN);
tryToLinkToRoom();
resolve();
}).catch(reject);
}
});
}
})
}

Expand Down

0 comments on commit 70bf726

Please sign in to comment.