mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
QR Code Login Flow (#2767)
Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Hugh Nimmo-Smith <hughns@element.io>
This commit is contained in:
@@ -444,10 +444,16 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
}
|
||||
|
||||
private func startAuthentication() {
|
||||
let encryptionKeyProvider = EncryptionKeyProvider()
|
||||
let authenticationService = AuthenticationServiceProxy(userSessionStore: userSessionStore,
|
||||
encryptionKeyProvider: EncryptionKeyProvider(),
|
||||
encryptionKeyProvider: encryptionKeyProvider,
|
||||
appSettings: appSettings)
|
||||
let qrCodeLoginService = QRCodeLoginService(oidcConfiguration: appSettings.oidcConfiguration.rustValue,
|
||||
encryptionKeyProvider: encryptionKeyProvider,
|
||||
userSessionStore: userSessionStore)
|
||||
|
||||
authenticationFlowCoordinator = AuthenticationFlowCoordinator(authenticationService: authenticationService,
|
||||
qrCodeLoginService: qrCodeLoginService,
|
||||
bugReportService: ServiceLocator.shared.bugReportService,
|
||||
navigationRootCoordinator: navigationRootCoordinator,
|
||||
appMediator: appMediator,
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import AVFoundation
|
||||
import UIKit
|
||||
|
||||
class AppMediator: AppMediatorProtocol {
|
||||
@@ -64,4 +65,22 @@ class AppMediator: AppMediatorProtocol {
|
||||
func setIdleTimerDisabled(_ disabled: Bool) {
|
||||
application.isIdleTimerDisabled = disabled
|
||||
}
|
||||
|
||||
func requestAuthorizationIfNeeded() async -> Bool {
|
||||
let status = AVCaptureDevice.authorizationStatus(for: .video)
|
||||
|
||||
// Determine if the user previously authorized camera access.
|
||||
if status == .authorized {
|
||||
return true
|
||||
}
|
||||
|
||||
var isAuthorized = false
|
||||
// If the system hasn't determined the user's authorization status,
|
||||
// explicitly prompt them for approval.
|
||||
if status == .notDetermined {
|
||||
isAuthorized = await AVCaptureDevice.requestAccess(for: .video)
|
||||
}
|
||||
|
||||
return isAuthorized
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ protocol AppMediatorProtocol {
|
||||
func openAppSettings()
|
||||
|
||||
func setIdleTimerDisabled(_ disabled: Bool)
|
||||
|
||||
func requestAuthorizationIfNeeded() async -> Bool
|
||||
}
|
||||
|
||||
extension UIApplication.State: CustomStringConvertible {
|
||||
|
||||
@@ -154,6 +154,15 @@ final class AppSettings {
|
||||
return url
|
||||
}()
|
||||
|
||||
private(set) lazy var oidcConfiguration = OIDCConfigurationProxy(clientName: InfoPlistReader.main.bundleDisplayName,
|
||||
redirectURI: oidcRedirectURL,
|
||||
clientURI: websiteURL,
|
||||
logoURI: logoURL,
|
||||
tosURI: acceptableUseURL,
|
||||
policyURI: privacyURL,
|
||||
contacts: [supportEmailAddress],
|
||||
staticRegistrations: oidcStaticRegistrations.mapKeys { $0.absoluteString })
|
||||
|
||||
/// A dictionary of accounts that have performed an initial sync through their proxy.
|
||||
///
|
||||
/// This is a temporary workaround. In the future we should be able to receive a signal from the
|
||||
|
||||
Reference in New Issue
Block a user