Skip to content

Commit

Permalink
[ONC-39] Check that signed in user matches wallet (#7812)
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson authored Mar 13, 2024
1 parent c966eae commit e6267f1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/web/src/common/store/account/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ export function* fetchAccountAsync({ isSignUp = false }) {
const clientOrigin = isNativeMobile
? 'mobile'
: isElectron
? 'desktop'
: 'web'
? 'desktop'
: 'web'
fingerprintClient.identify(account.user_id, clientOrigin)

yield call(recordIPIfNotRecent, account.handle)
Expand All @@ -192,13 +192,19 @@ export function* fetchAccountAsync({ isSignUp = false }) {

export function* fetchLocalAccountAsync() {
const localStorage = yield getContext('localStorage')
const audiusBackendInstance = yield getContext('audiusBackendInstance')

yield put(accountActions.fetchAccountRequested())

const audiusLibs = yield call([audiusBackendInstance, audiusBackendInstance.getAudiusLibs])
const wallet = yield call([audiusLibs.web3Manager, audiusLibs.web3Manager.getWalletAddress])
const cachedAccount = yield call([localStorage, 'getAudiusAccount'])
const cachedAccountUser = yield call([localStorage, 'getAudiusAccountUser'])
const currentUserExists = yield call([localStorage, 'getCurrentUserExists'])
if (cachedAccount && cachedAccountUser && !cachedAccountUser.is_deactivated) {

const walletMatches = wallet.toLowerCase() === cachedAccountUser.wallet.toLowerCase()

if (cachedAccount && cachedAccountUser && !cachedAccountUser.is_deactivated && walletMatches) {
yield call(
cacheAccount,
{ ...cachedAccountUser, local: true },
Expand Down

0 comments on commit e6267f1

Please sign in to comment.