better handle bad wallet password errors

This commit is contained in:
Sean Yesmunt 2020-11-12 14:47:39 -05:00
parent f1adfddded
commit abacafb0c5
4 changed files with 12 additions and 10 deletions

View file

@ -136,7 +136,7 @@
"imagesloaded": "^4.1.4",
"json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#72ead945cc7cb96e36d67638981ecdc921e5f663",
"lbry-redux": "lbryio/lbry-redux#2c609a21bbb25b431d323d73fa566c40c1b40bc5",
"lbryinc": "lbryio/lbryinc#2a9d04b2efcae0a68b7315bf04632db4a757461c",
"lint-staged": "^7.0.2",
"localforage": "^1.7.1",

View file

@ -10,6 +10,7 @@ import { selectUserVerifiedEmail } from 'redux/selectors/user';
let syncTimer = null;
const SYNC_INTERVAL = 1000 * 60 * 5; // 5 minutes
const NO_WALLET_ERROR = 'no wallet found for this user';
const BAD_PASSWORD_ERROR_NAME = 'InvalidPasswordError';
export function doSetDefaultAccount(success, failure) {
return dispatch => {
@ -198,10 +199,13 @@ export function doGetSync(passedPassword, callback) {
handleCallback(null, data.changed);
})
.catch(syncAttemptError => {
const badPasswordError =
syncAttemptError && syncAttemptError.data && syncAttemptError.data.name === BAD_PASSWORD_ERROR_NAME;
if (data.unlockFailed) {
dispatch({ type: ACTIONS.GET_SYNC_FAILED, data: { error: syncAttemptError } });
if (password !== '') {
if (badPasswordError) {
dispatch({ type: ACTIONS.SYNC_APPLY_BAD_PASSWORD });
}
@ -215,10 +219,7 @@ export function doGetSync(passedPassword, callback) {
},
});
// Temp solution until we have a bad password error code
// Don't fail on blank passwords so we don't show a "password error" message
// before users have ever entered a password
if (password !== '') {
if (badPasswordError) {
dispatch({ type: ACTIONS.SYNC_APPLY_BAD_PASSWORD });
}

View file

@ -104,10 +104,11 @@ reducers[ACTIONS.SYNC_APPLY_BAD_PASSWORD] = state =>
syncApplyPasswordError: true,
});
reducers[LBRY_REDUX_ACTIONS.SYNC_FATAL_ERROR] = state =>
Object.assign({}, state, {
reducers[LBRY_REDUX_ACTIONS.SYNC_FATAL_ERROR] = (state, action) => {
return Object.assign({}, state, {
fatalError: true,
});
};
reducers[ACTIONS.SYNC_RESET] = () => defaultState;

View file

@ -7411,9 +7411,9 @@ lazy-val@^1.0.4:
yargs "^13.2.2"
zstd-codec "^0.1.1"
lbry-redux@lbryio/lbry-redux#72ead945cc7cb96e36d67638981ecdc921e5f663:
lbry-redux@lbryio/lbry-redux#2c609a21bbb25b431d323d73fa566c40c1b40bc5:
version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/72ead945cc7cb96e36d67638981ecdc921e5f663"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/2c609a21bbb25b431d323d73fa566c40c1b40bc5"
dependencies:
proxy-polyfill "0.1.6"
reselect "^3.0.0"