Skip to content

Commit

Permalink
add disable authenticated sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
llbartekll committed Jun 13, 2024
1 parent e0d14d9 commit 9d8b464
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions Sources/Web3Modal/Core/Web3Modal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public class Web3Modal {
try? await w3mApiInteractor.fetchWalletImages(for: [wallet])
}
}

}

#if canImport(UIKit)
Expand Down
10 changes: 10 additions & 0 deletions Sources/Web3Modal/Core/Web3ModalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,14 @@ public class Web3ModalClient {
public func disableAnalytics() {
analyticsService.disable()
}

#if DEBUG
public func disableAuthenticatedSessions() {
Web3Modal.viewModel.authenticatedSessionsDisabled = true
}

public func enableAuthenticatedSessions() {
Web3Modal.viewModel.authenticatedSessionsDisabled = false
}
#endif
}
12 changes: 11 additions & 1 deletion Sources/Web3Modal/Sheets/Web3ModalViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class Web3ModalViewModel: ObservableObject {
private(set) var signInteractor: SignInteractor
private(set) var blockchainApiInteractor: BlockchainAPIInteractor
private let supportsAuthenticatedSession: Bool
#if DEBUG
var authenticatedSessionsDisabled = false
#endif

private var disposeBag = Set<AnyCancellable>()

Expand Down Expand Up @@ -61,8 +64,15 @@ class Web3ModalViewModel: ObservableObject {

signInteractor.sessionSettlePublisher
.receive(on: DispatchQueue.main)
.sink { session in
.sink { [weak self] session in
guard let self = self else { return }
self.handleNewSession(session: session)
#if DEBUG
if self.authenticatedSessionsDisabled {
self.routeToProfile()
return
}
#endif
if supportsAuthenticatedSession {
self.handleSIWEFallback()
} else {
Expand Down

0 comments on commit 9d8b464

Please sign in to comment.