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 // 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'; 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( dispatch(
doAuthenticate( doAuthenticate(
appVersion, appVersion,

View file

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