diff --git a/components/WalletHeader.tsx b/components/WalletHeader.tsx index 117480521..ea89aabec 100644 --- a/components/WalletHeader.tsx +++ b/components/WalletHeader.tsx @@ -49,7 +49,7 @@ const protectedNavigation = async ( attemptAdminLogin: true }); } else { - if (disactivatePOS) await setPosStatus('inactive'); + if (disactivatePOS) setPosStatus('inactive'); navigation.navigate(route); } }; @@ -113,7 +113,7 @@ const POSBadge = ({ { getOrders(); - await setPosStatus('active'); + setPosStatus('active'); }} > diff --git a/stores/SettingsStore.ts b/stores/SettingsStore.ts index 4c8462e0f..69060fbfd 100644 --- a/stores/SettingsStore.ts +++ b/stores/SettingsStore.ts @@ -1002,14 +1002,15 @@ export default class SettingsStore { }); }; - public loginRequired = () => + public loginRequired = () => this.loginMethodConfigured() && !this.loggedIn; + + public loginMethodConfigured = () => this.settings && (this.settings.passphrase || this.settings.pin || - this.isBiometryRequired()) && - !this.loggedIn; + this.isBiometryConfigured()); - public isBiometryRequired = () => + public isBiometryConfigured = () => this.settings != null && this.settings.isBiometryEnabled && this.settings.supportedBiometryType !== undefined; diff --git a/views/Lockscreen.tsx b/views/Lockscreen.tsx index 9254c7454..9dda3d411 100644 --- a/views/Lockscreen.tsx +++ b/views/Lockscreen.tsx @@ -76,10 +76,10 @@ export default class Lockscreen extends React.Component< const posEnabled: boolean = (settings && settings.pos && settings.pos.squareEnabled) || false; - const isBiometryRequired = SettingsStore.isBiometryRequired(); + const isBiometryConfigured = SettingsStore.isBiometryConfigured(); if ( - isBiometryRequired && + isBiometryConfigured && !attemptAdminLogin && !deletePin && !deleteDuressPin && @@ -184,7 +184,7 @@ export default class Lockscreen extends React.Component< } else if (deleteDuressPin) { this.deleteDuressPin(); } else { - await setPosStatus('inactive'); + setPosStatus('inactive'); this.resetAuthenticationAttempts(); navigation.navigate('Wallet'); } diff --git a/views/Wallet/Wallet.tsx b/views/Wallet/Wallet.tsx index 4f68549be..11036dfa2 100644 --- a/views/Wallet/Wallet.tsx +++ b/views/Wallet/Wallet.tsx @@ -149,7 +149,8 @@ export default class Wallet extends React.Component { tabNavigatorState.routeNames[tabNavigatorState.index]; const defaultView = this.props.SettingsStore.settings.display.defaultView; - if (defaultView === currentTabName) { + + if (defaultView === currentTabName || currentTabName === 'POS') { return false; } else if (defaultView) { tabNavigator.navigate(defaultView); @@ -187,15 +188,17 @@ export default class Wallet extends React.Component { const { settings } = SettingsStore; const { loginBackground } = settings; - const loginRequired = SettingsStore.loginRequired(); - - if (nextAppState === 'background' && loginRequired && loginBackground) { + if ( + nextAppState === 'background' && + SettingsStore.loginMethodConfigured() && + loginBackground + ) { // In case the lock screen is visible and a valid PIN is entered and home button is pressed, // unauthorized access would be possible because the PIN is not cleared on next launch. // By calling pop, the lock screen is closed to clear the PIN. this.props.navigation.pop(); SettingsStore.setLoginStatus(false); - } else if (nextAppState === 'active' && loginRequired) { + } else if (nextAppState === 'active' && SettingsStore.loginRequired()) { this.props.navigation.navigate('Lockscreen'); } }; @@ -219,7 +222,7 @@ export default class Wallet extends React.Component { if (posEnabled && posStatus === 'inactive' && loginRequired) { navigation.navigate('Lockscreen'); } else if (posEnabled && posStatus === 'unselected') { - await setPosStatus('active'); + setPosStatus('active'); if (!this.state.unlocked) { this.startListeners(); this.setState({ unlocked: true }); @@ -350,7 +353,7 @@ export default class Wallet extends React.Component { const error = NodeInfoStore.error || SettingsStore.error; const { implementation, settings, loggedIn, connecting, posStatus } = SettingsStore; - const loginRequired = SettingsStore.loginRequired(); + const loginRequired = !settings || SettingsStore.loginRequired(); const squareEnabled: boolean = (settings && settings.pos && settings.pos.squareEnabled) || false;