Skip to content

Commit

Permalink
Reset pincode cache if unlock fails (#1430)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcewen authored and celo-ci-bot-user committed Oct 22, 2019
1 parent 3bf4177 commit b07c091
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/mobile/src/pincode/PincodeCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function getCachedPincode() {
return null
}

export function setCachedPincode(pincode: string) {
export function setCachedPincode(pincode: string | null) {
pincodeCache.timestamp = Date.now()
pincodeCache.pincode = pincode
}
2 changes: 2 additions & 0 deletions packages/mobile/src/web3/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { UNLOCK_DURATION } from 'src/geth/consts'
import { deleteChainData } from 'src/geth/geth'
import { navigateToError } from 'src/navigator/NavigationService'
import { waitWeb3LastBlock } from 'src/networkInfo/saga'
import { setCachedPincode } from 'src/pincode/PincodeCache'
import { setKey } from 'src/utils/keyStore'
import Logger from 'src/utils/Logger'
import {
Expand Down Expand Up @@ -323,6 +324,7 @@ export function* unlockAccount(account: string) {
return true
}
} catch (error) {
setCachedPincode(null)
Logger.error(TAG + '@unlockAccount', 'Web3 account unlock failed', error)
return false
}
Expand Down

0 comments on commit b07c091

Please sign in to comment.