Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Ref #7980: [Follow up to #7952] Opening in private from home screen w…
Browse files Browse the repository at this point in the history
…ill bypass biometrics (#8011)
  • Loading branch information
soner-yuksel authored and iccub committed Sep 1, 2023
1 parent d86b2cc commit e4842fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/Brave/Frontend/Browser/NavigationRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public enum NavigationPath: Equatable {
bvc.openBlankNewTab(attemptLocationFieldFocus: false, isPrivate: true)
} else {
if Preferences.Privacy.privateBrowsingLock.value {
bvc.askForLocalAuthentication(viewType: .widget) { [weak bvc] success, _ in
bvc.askForLocalAuthentication(viewType: .external) { [weak bvc] success, _ in
if success {
bvc?.openBlankNewTab(attemptLocationFieldFocus: false, isPrivate: true)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Brave/Frontend/Browser/QuickActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class QuickActions: NSObject {
handleOpenNewTab(withBrowserViewController: browserViewController, isPrivate: true)
} else {
if Preferences.Privacy.privateBrowsingLock.value {
browserViewController.askForLocalAuthentication(viewType: .widget) { [weak self] success, _ in
browserViewController.askForLocalAuthentication(viewType: .external) { [weak self] success, _ in
if success {
self?.handleOpenNewTab(withBrowserViewController: browserViewController, isPrivate: true)
}
Expand Down
10 changes: 6 additions & 4 deletions Sources/Brave/Frontend/Passcode/WindowProtection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import SwiftKeychainWrapper
import os.log

public enum AuthViewType {
case general, widget, sync, tabTray, passwords
case external, general, sync, tabTray, passwords
}

public class WindowProtection {
Expand Down Expand Up @@ -165,7 +165,7 @@ public class WindowProtection {
.sink(receiveValue: { [weak self] _ in
guard let self = self else { return }
self.context = LAContext() // Reset context for new session
self.updateVisibleStatusForForeground()
self.updateVisibleStatusForForeground(viewType: .external)
})
.store(in: &cancellables)
}
Expand Down Expand Up @@ -211,13 +211,15 @@ public class WindowProtection {
}

private func presentLocalAuthentication(viewType: AuthViewType, completion: ((Bool, LAError.Code?) -> Void)? = nil) {
self.viewType = viewType

if !context.canEvaluatePolicy(.deviceOwnerAuthentication, error: nil) {
completion?(false, .passcodeNotSet)
return
}

lockedViewController.unlockButton.isHidden = true
if viewType == .widget {
if viewType == .external {
isCancellable = false
}

Expand All @@ -235,7 +237,7 @@ public class WindowProtection {
completion?(true, nil)
})
} else {
lockedViewController.unlockButton.isHidden = viewType == .general || viewType == .widget
lockedViewController.unlockButton.isHidden = viewType == .general

let errorPolicy = error as? LAError
completion?(false, errorPolicy?.code)
Expand Down

0 comments on commit e4842fb

Please sign in to comment.