Skip to content

Commit

Permalink
fix: fix microsoft login issue on iOS after config branch merges (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedbashir authored Nov 25, 2024
1 parent 264fb81 commit d2fc507
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Core/Core/Configuration/Config/MicrosoftConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import Foundation

private enum MicrosoftKeys: String {
case enabled = "ENABLED"
case appID = "APP_ID"
case clientID = "CLIENT_ID"
}

public final class MicrosoftConfig: NSObject {
public var enabled: Bool = false
private(set) var appID: String?
private(set) var clientID: String?

private var requiredKeysAvailable: Bool {
return appID != nil
return clientID != nil
}

init(dictionary: [String: AnyObject]) {
appID = dictionary[MicrosoftKeys.appID.rawValue] as? String
clientID = dictionary[MicrosoftKeys.clientID.rawValue] as? String
super.init()
enabled = requiredKeysAvailable && dictionary[MicrosoftKeys.enabled.rawValue] as? Bool == true
}
Expand Down
5 changes: 3 additions & 2 deletions Core/Core/Providers/SocialAuth/MicrosoftAuthProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ public final class MicrosoftAuthProvider {
}

private func createClientApplication() throws -> MSALPublicClientApplication {
guard let config = Container.shared.resolve(ConfigProtocol.self), let appID = config.microsoft.appID else {
guard let config = Container.shared.resolve(ConfigProtocol.self),
let clientID = config.microsoft.clientID else {
throw SocialAuthError.error(text: "Configuration error")
}
let configuration = MSALPublicClientApplicationConfig(clientId: appID)
let configuration = MSALPublicClientApplicationConfig(clientId: clientID)

do {
return try MSALPublicClientApplication(configuration: configuration)
Expand Down
4 changes: 2 additions & 2 deletions Core/CoreTests/Configuration/ConfigTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ConfigTests: XCTestCase {
],
"MICROSOFT": [
"ENABLED": true,
"APP_ID": "appId"
"CLIENT_ID": "cliendID"
],
"APPLE_SIGNIN": [
"ENABLED": true
Expand Down Expand Up @@ -119,7 +119,7 @@ class ConfigTests: XCTestCase {
let config = Config(properties: properties)

XCTAssertTrue(config.microsoft.enabled)
XCTAssertEqual(config.microsoft.appID, "appId")
XCTAssertEqual(config.microsoft.clientID, "cliendID")
}

func testAppleConfigInitialization() {
Expand Down
2 changes: 1 addition & 1 deletion Documentation/CONFIGURATION_MANAGEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ FIREBASE:
MICROSOFT:
ENABLED: true
APP_ID: "microsoftAppID"
CLIENT_ID: "microsoftAppID"
```

`shared.yaml`:
Expand Down

0 comments on commit d2fc507

Please sign in to comment.