better user errors

This commit is contained in:
zeppi 2021-09-21 15:12:52 -04:00
parent 6f27525ec2
commit b5383a312e
2 changed files with 18 additions and 17 deletions

View file

@ -359,10 +359,7 @@ export function doLbryReady() {
// TODO: call doFetchDaemonSettings, then get usage data, and call doAuthenticate once they are loaded into the store
const shareUsageData = IS_WEB || window.localStorage.getItem(SHARE_INTERNAL) === 'true';
/**
* doAuthenticate -> Lbryio.authenticate, then update redux with auth token.
* authenticate: Use auth token to get or create user.getCurrentUser. return user
*/
dispatch(
doAuthenticate(
appVersion,

View file

@ -131,11 +131,14 @@ export function doAuthenticate(
const user = await Lbryio.fetchUser(DOMAIN, getDefaultLanguage());
console.log('USER', user);
if (sessionStorageAvailable) window.sessionStorage.removeItem(AUTH_IN_PROGRESS);
// put this back , accessToken: tokens.access_token
// put this back: accessToken: tokens.access_token
if (user.error) {
throw new Error(user.error.message);
} else {
Lbryio.getTokens().then((tokens) => {
dispatch({
type: ACTIONS.AUTHENTICATION_SUCCESS,
data: { user, accessToken: tokens.auth_token }, // rename 'accessToken' = auth_token
data: { user, accessToken: tokens.auth_token }, // rename 'accessToken' = authToken
});
if (shareUsageData) {
dispatch(doRewardList());
@ -145,6 +148,7 @@ export function doAuthenticate(
}
}
});
}
} catch (error) {
if (sessionStorageAvailable) window.sessionStorage.removeItem(AUTH_IN_PROGRESS);