Skip to content

Commit

Permalink
Merge pull request #1086 from tchapgouv/1083-activer-la-connexion-sso
Browse files Browse the repository at this point in the history
Activer la connexion sso
  • Loading branch information
NicolasBuquet authored Oct 7, 2024
2 parents 3da99a9 + c660860 commit 24dfb09
Show file tree
Hide file tree
Showing 19 changed files with 302 additions and 669 deletions.
1 change: 1 addition & 0 deletions Btchap/SupportingFiles/Btchap-App-Common.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ BUNDLE_DISPLAY_NAME = Btchap
BASE_BUNDLE_IDENTIFIER = fr.gouv.btchap
APPLICATION_GROUP_IDENTIFIER = group.$(BASE_BUNDLE_IDENTIFIER)
PRODUCT_BUNDLE_IDENTIFIER = $(BASE_BUNDLE_IDENTIFIER)
APPLICATION_SCHEME = tchap

INFOPLIST_FILE = Btchap/SupportingFiles/Info.plist
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
Expand Down
13 changes: 13 additions & 0 deletions Btchap/SupportingFiles/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>$(BASE_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(APPLICATION_SCHEME)</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>ITSAppUsesNonExemptEncryption</key>
Expand Down
1 change: 1 addition & 0 deletions DevTchap/SupportingFiles/DevTchap-App-Common.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ BUNDLE_DISPLAY_NAME = DevTchap
BASE_BUNDLE_IDENTIFIER = fr.gouv.tchap.dev
APPLICATION_GROUP_IDENTIFIER = group.$(BASE_BUNDLE_IDENTIFIER)
PRODUCT_BUNDLE_IDENTIFIER = $(BASE_BUNDLE_IDENTIFIER)
APPLICATION_SCHEME = tchap

INFOPLIST_FILE = DevTchap/SupportingFiles/Info.plist
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
Expand Down
13 changes: 13 additions & 0 deletions DevTchap/SupportingFiles/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>$(BASE_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(APPLICATION_SCHEME)</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>ITSAppUsesNonExemptEncryption</key>
Expand Down
36 changes: 35 additions & 1 deletion Riot/Modules/Authentication/AuthenticationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
if authenticationService.state.homeserver.needsRegistrationFallback {
showFallback(for: flow)
} else {
showRegistrationScreen()
// Tchap: force email registration mode
// showRegistrationScreen()
TchapShowVerifyEmailScreen()
}
case .login:
if authenticationService.state.homeserver.needsLoginFallback {
Expand Down Expand Up @@ -379,6 +381,38 @@ final class AuthenticationCoordinator: NSObject, AuthenticationCoordinatorProtoc
}
}

// Tchap: start Registration with VerifyEmail screen
/// Shows the login screen.
@MainActor private func TchapShowVerifyEmailScreen() {
MXLog.debug("[AuthenticationCoordinator] TchapShowVerifyEmailScreen")

guard let registrationWizard = authenticationService.registrationWizard else {
MXLog.failure("[AuthenticationCoordinator] showStage: Missing the RegistrationWizard needed to complete the stage.")
displayError(message: VectorL10n.errorCommonMessage)
return
}
let homeserver = authenticationService.state.homeserver

let parameters = AuthenticationVerifyEmailCoordinatorParameters(registrationWizard: registrationWizard,
homeserver: authenticationService.state.homeserver)
let coordinator = AuthenticationVerifyEmailCoordinator(parameters: parameters)
coordinator.callback = { [weak self] result in
self?.registrationStageDidComplete(with: result)
}

coordinator.start()
add(childCoordinator: coordinator)

if navigationRouter.modules.isEmpty {
navigationRouter.setRootModule(coordinator, popCompletion: nil)
} else {
navigationRouter.push(coordinator, animated: true) { [weak self] in
self?.remove(childCoordinator: coordinator)
}
}
}


/// Displays the next view in the flow based on the result from the registration screen.
@MainActor private func registrationCoordinator(_ coordinator: AuthenticationRegistrationCoordinator,
didCallbackWith result: AuthenticationRegistrationCoordinatorResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ - (void)viewDidLoad
}
else
{
self.defaultHomeServerUrl = RiotSettings.shared.homeserverUrlString;
// self.defaultHomeServerUrl = RiotSettings.shared.homeserverUrlString;
}

self.defaultIdentityServerUrl = RiotSettings.shared.identityServerUrlString;
// self.defaultIdentityServerUrl = RiotSettings.shared.identityServerUrlString;

self.welcomeImageView.image = AssetSharedImages.horizontalLogo.image;

Expand Down
54 changes: 25 additions & 29 deletions Riot/Modules/Home/AllChats/AllChatsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ class AllChatsViewController: HomeViewController {

// Reference to the current onboarding flow. It is always nil unless the flow is being presented.
private(set) var onboardingCoordinatorBridgePresenter: OnboardingCoordinatorBridgePresenter?
// Tchap: Use welcomeCoordinator instead of onboardingCoordinator
private(set) var welcomeCoordinatorBridgePresenter: WelcomeCoordinatorBridgePresenter?

// Tell whether the onboarding screen is preparing.
private(set) var isOnboardingInProgress: Bool = false
Expand Down Expand Up @@ -921,8 +919,7 @@ extension AllChatsViewController: SplitViewMasterViewControllerProtocol {
// This method can be called after the user chooses to clear their data as the MXSession
// is opened to call logout from. So we only set the credentials when authentication isn't
// in progress to prevent a second soft logout screen being shown.
// Tchap: Use WelcomeCoordinatorBridgePresenter instead of OnboardingCoordinatorBridgePresenter
guard self.welcomeCoordinatorBridgePresenter == nil && !self.isOnboardingCoordinatorPreparing else {
guard self.self.onboardingCoordinatorBridgePresenter == nil && !self.isOnboardingCoordinatorPreparing else {
return
}

Expand Down Expand Up @@ -1092,8 +1089,7 @@ extension AllChatsViewController: SplitViewMasterViewControllerProtocol {

private func showOnboardingFlowAndResetSessionFlags(_ resetSessionFlags: Bool) {
// Check whether an authentication screen is not already shown or preparing
// Tchap: Use WelcomeCoordinatorBridgePresenter instead of OnboardingCoordinatorBridgePresenter
guard self.welcomeCoordinatorBridgePresenter == nil && !self.isOnboardingCoordinatorPreparing else {
guard self.self.onboardingCoordinatorBridgePresenter == nil && !self.isOnboardingCoordinatorPreparing else {
return
}

Expand All @@ -1117,36 +1113,36 @@ extension AllChatsViewController: SplitViewMasterViewControllerProtocol {
MXLog.debug("[AllChatsViewController] presentOnboardingFlow")

// Tchap: Use WelcomeCoordinatorBridgePresenter instead of OnboardingCoordinatorBridgePresenter
let welcomeCoordinatorBridgePresenter = WelcomeCoordinatorBridgePresenter()
welcomeCoordinatorBridgePresenter.completion = { [weak self] in
guard let self = self else { return }

self.welcomeCoordinatorBridgePresenter?.dismiss(animated: true, completion: {
self.welcomeCoordinatorBridgePresenter = nil
})

self.isOnboardingInProgress = false // Must be set before calling didCompleteAuthentication
self.allChatsDelegate?.allChatsViewControllerDidCompleteAuthentication(self)
}

welcomeCoordinatorBridgePresenter.present(from: self, animated: true)
self.welcomeCoordinatorBridgePresenter = welcomeCoordinatorBridgePresenter


// let onboardingCoordinatorBridgePresenter = OnboardingCoordinatorBridgePresenter()
// onboardingCoordinatorBridgePresenter.completion = { [weak self] in
// let welcomeCoordinatorBridgePresenter = WelcomeCoordinatorBridgePresenter()
// welcomeCoordinatorBridgePresenter.completion = { [weak self] in
// guard let self = self else { return }
//
// self.onboardingCoordinatorBridgePresenter?.dismiss(animated: true, completion: {
// self.onboardingCoordinatorBridgePresenter = nil
//
// self.welcomeCoordinatorBridgePresenter?.dismiss(animated: true, completion: {
// self.welcomeCoordinatorBridgePresenter = nil
// })
//
// self.isOnboardingInProgress = false // Must be set before calling didCompleteAuthentication
// self.allChatsDelegate?.allChatsViewControllerDidCompleteAuthentication(self)
// }
//
// onboardingCoordinatorBridgePresenter.present(from: self, animated: true)
// self.onboardingCoordinatorBridgePresenter = onboardingCoordinatorBridgePresenter
// welcomeCoordinatorBridgePresenter.present(from: self, animated: true)
// self.welcomeCoordinatorBridgePresenter = welcomeCoordinatorBridgePresenter


let onboardingCoordinatorBridgePresenter = OnboardingCoordinatorBridgePresenter()
onboardingCoordinatorBridgePresenter.completion = { [weak self] in
guard let self = self else { return }

self.onboardingCoordinatorBridgePresenter?.dismiss(animated: true, completion: {
self.onboardingCoordinatorBridgePresenter = nil
})

self.isOnboardingInProgress = false // Must be set before calling didCompleteAuthentication
self.allChatsDelegate?.allChatsViewControllerDidCompleteAuthentication(self)
}

onboardingCoordinatorBridgePresenter.present(from: self, animated: true)
self.onboardingCoordinatorBridgePresenter = onboardingCoordinatorBridgePresenter
self.isOnboardingCoordinatorPreparing = false
}

Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Onboarding/OnboardingCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
case .register:
// Tchap: Bypass usecase selection screen
// showUseCaseSelectionScreen()
MXLog.failure("[OnboardingCoordinator] splashScreenCoordinator register case should not happen !")
beginAuthentication(with: .registration, onStart: coordinator.stop)

case .login:
if BuildSettings.onboardingEnableNewAuthenticationFlow {
Expand Down
21 changes: 12 additions & 9 deletions Riot/Modules/SplitView/SplitViewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType {
self.splitViewController.delegate = self

// Create primary controller
let masterCoordinator: SplitViewMasterCoordinatorProtocol = BuildSettings.newAppLayoutEnabled ? self.createAllChatsCoordinator() : self.createTabBarCoordinator()
// Tchap: force using AllChatsCoordinator because newLayout is always TRUE
// let masterCoordinator: SplitViewMasterCoordinatorProtocol = BuildSettings.newAppLayoutEnabled ? self.createAllChatsCoordinator() : self.createTabBarCoordinator()
let masterCoordinator: SplitViewMasterCoordinatorProtocol = self.createAllChatsCoordinator()
masterCoordinator.splitViewMasterPresentableDelegate = self
masterCoordinator.start(with: spaceId)

Expand Down Expand Up @@ -182,14 +184,15 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType {
return coordinator
}

private func createTabBarCoordinator() -> TabBarCoordinator {

let coordinatorParameters = TabBarCoordinatorParameters(userSessionsService: self.parameters.userSessionsService, appNavigator: self.parameters.appNavigator)

let tabBarCoordinator = TabBarCoordinator(parameters: coordinatorParameters)
tabBarCoordinator.delegate = self
return tabBarCoordinator
}
// Tchap: don't use TabBarCoordinator anymore now that newLayout is always TRUE
// private func createTabBarCoordinator() -> TabBarCoordinator {
//
// let coordinatorParameters = TabBarCoordinatorParameters(userSessionsService: self.parameters.userSessionsService, appNavigator: self.parameters.appNavigator)
//
// let tabBarCoordinator = TabBarCoordinator(parameters: coordinatorParameters)
// tabBarCoordinator.delegate = self
// return tabBarCoordinator
// }

private func resetDetailNavigationControllerWithPlaceholder(animated: Bool) {
guard let detailNavigationRouter = self.detailNavigationRouter else {
Expand Down
32 changes: 17 additions & 15 deletions Riot/Modules/TabBar/TabBarCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,14 @@ final class TabBarCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
}

private func showWelcome(animated: Bool = false) {
let welcomeCoordinator = WelcomeCoordinator()
welcomeCoordinator.delegate = self
welcomeCoordinator.start()
self.add(childCoordinator: welcomeCoordinator)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5 , execute: { [weak self] in
self?.navigationRouter.present(welcomeCoordinator, animated: animated)
})
// Tchap: remove calls to Welcome classes
// let welcomeCoordinator = WelcomeCoordinator()
// welcomeCoordinator.delegate = self
// welcomeCoordinator.start()
// self.add(childCoordinator: welcomeCoordinator)
// DispatchQueue.main.asyncAfter(deadline: .now() + 0.5 , execute: { [weak self] in
// self?.navigationRouter.present(welcomeCoordinator, animated: animated)
// })
}

private func userDidLogin() -> Bool {
Expand Down Expand Up @@ -1163,14 +1164,15 @@ extension TabBarCoordinator: SecureBackupSetupCoordinatorBridgePresenterDelegate
}

// MARK: - WelcomeCoordinatorDelegate
extension TabBarCoordinator: WelcomeCoordinatorDelegate {
func welcomeCoordinatorUserDidAuthenticate(_ coordinator: WelcomeCoordinatorType) {
// Check that the new account actually exists before removing the current coordinator
if userDidLogin() {
self.remove(childCoordinator: coordinator)
}
}
}
// Tchap: remove calls to Tchap Welcome classes
//extension TabBarCoordinator: WelcomeCoordinatorDelegate {
// func welcomeCoordinatorUserDidAuthenticate(_ coordinator: WelcomeCoordinatorType) {
// // Check that the new account actually exists before removing the current coordinator
// if userDidLogin() {
// self.remove(childCoordinator: coordinator)
// }
// }
//}

// MARK: - RoomsViewControllerDelegate
extension TabBarCoordinator: RoomsViewControllerDelegate {
Expand Down
Loading

0 comments on commit 24dfb09

Please sign in to comment.