Skip to content

Commit

Permalink
MBL-1158: Add stub for presenting OAuth login controller when feature…
Browse files Browse the repository at this point in the history
… flag is enabled
  • Loading branch information
amy-at-kickstarter committed Feb 1, 2024
1 parent 905c9d7 commit 856d19c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,20 @@ public final class LoginToutViewController: UIViewController, MFMailComposeViewC
}

fileprivate func pushLoginViewController() {
self.navigationController?.pushViewController(LoginViewController.instantiate(), animated: true)
self.navigationItem.backBarButtonItem = UIBarButtonItem.back(nil, selector: nil)
if featureLoginWithOAuthEnabled() {
let session = ASWebAuthenticationSession(
url: OAuth.authorizationURL(),
callbackURLScheme: OAuth.redirectScheme
) { _, _ in
// TODO: MBL-1159: Get required information from the callback; call mutation to login.
}

session.presentationContextProvider = self
session.start()
} else {
self.navigationController?.pushViewController(LoginViewController.instantiate(), animated: true)
self.navigationItem.backBarButtonItem = UIBarButtonItem.back(nil, selector: nil)
}
}

fileprivate func pushTwoFactorViewController(facebookAccessToken token: String) {
Expand Down Expand Up @@ -623,3 +635,11 @@ extension LoginToutViewController: ASAuthorizationControllerPresentationContextP
return window
}
}

// MARK: - ASWebAuthenticationPresentationContextProviding

extension LoginToutViewController: ASWebAuthenticationPresentationContextProviding {
public func presentationAnchor(for _: ASWebAuthenticationSession) -> ASPresentationAnchor {
return self.view.window!
}
}
4 changes: 4 additions & 0 deletions Kickstarter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,7 @@
E10D06632ACF385E00470B5C /* FetchBackerProjectsQuery.json in Resources */ = {isa = PBXBuildFile; fileRef = E10D06622ACF385E00470B5C /* FetchBackerProjectsQuery.json */; };
E10D06652AD48C9C00470B5C /* FetchBackerProjectsQueryRequestForTests.graphql_test in Resources */ = {isa = PBXBuildFile; fileRef = E10D06642AD48C9C00470B5C /* FetchBackerProjectsQueryRequestForTests.graphql_test */; };
E10F75E82B6937FA00024AD1 /* PKCETest.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1EEED2A2B686829009976D9 /* PKCETest.swift */; };
E11CFE4B2B6C42CE00497375 /* OAuth.swift in Sources */ = {isa = PBXBuildFile; fileRef = E11CFE492B6C41B400497375 /* OAuth.swift */; };
E170B9112B20E83B001BEDD7 /* MockGraphQLClient+CombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E170B9102B20E83B001BEDD7 /* MockGraphQLClient+CombineTests.swift */; };
E1A1491E2ACDD76800F49709 /* FetchBackerProjectsQuery.graphql in Resources */ = {isa = PBXBuildFile; fileRef = E1A1491D2ACDD76700F49709 /* FetchBackerProjectsQuery.graphql */; };
E1A149202ACDD7BF00F49709 /* FetchProjectsEnvelope+FetchBackerProjectsQueryData.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1A1491F2ACDD7BF00F49709 /* FetchProjectsEnvelope+FetchBackerProjectsQueryData.swift */; };
Expand Down Expand Up @@ -3056,6 +3057,7 @@
E10BE8E52B151CC800F73DC9 /* BlockUserInputTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockUserInputTests.swift; sourceTree = "<group>"; };
E10D06622ACF385E00470B5C /* FetchBackerProjectsQuery.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = FetchBackerProjectsQuery.json; sourceTree = "<group>"; };
E10D06642AD48C9C00470B5C /* FetchBackerProjectsQueryRequestForTests.graphql_test */ = {isa = PBXFileReference; lastKnownFileType = text; path = FetchBackerProjectsQueryRequestForTests.graphql_test; sourceTree = "<group>"; };
E11CFE492B6C41B400497375 /* OAuth.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuth.swift; sourceTree = "<group>"; };
E170B9102B20E83B001BEDD7 /* MockGraphQLClient+CombineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MockGraphQLClient+CombineTests.swift"; sourceTree = "<group>"; };
E1889D8D2B6065D6004FBE21 /* CombineTestObserverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CombineTestObserverTests.swift; sourceTree = "<group>"; };
E1A1491D2ACDD76700F49709 /* FetchBackerProjectsQuery.graphql */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FetchBackerProjectsQuery.graphql; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5991,6 +5993,7 @@
A78537F71CB5803B00385B73 /* NSHTTPCookieStorageType.swift */,
37EB3E4B228CF4A400076E4C /* NumberFormatter.swift */,
37EB3E4D228CF4FB00076E4C /* NumberFormatterTests.swift */,
E11CFE492B6C41B400497375 /* OAuth.swift */,
94C92E7B2659EDBF00A96818 /* PaddingLabel.swift */,
A77D7B061CBAAF5D0077586B /* Paginate.swift */,
A7ED1F1C1E830FDC00BFFA01 /* PaginateTests.swift */,
Expand Down Expand Up @@ -7612,6 +7615,7 @@
064B007827A463D2007B21FE /* ImageViewElementCellViewModel.swift in Sources */,
A7F441E51D005A9400FE6FC5 /* SearchViewModel.swift in Sources */,
370F527A2254267900F159B9 /* UIApplicationType.swift in Sources */,
E11CFE4B2B6C42CE00497375 /* OAuth.swift in Sources */,
A75C81171D210BD700B5AD03 /* ShareViewModel.swift in Sources */,
6049D0202AA776B40015BB0D /* DesignSystemColors.swift in Sources */,
A757EAF01D1ABE7400A5C978 /* ActivitySurveyResponseCellViewModel.swift in Sources */,
Expand Down
12 changes: 12 additions & 0 deletions Library/OAuth.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

public struct OAuth {
public init() {}

public static let redirectScheme = "ksrauth2"
public static func authorizationURL() -> URL {
let base = AppEnvironment.current.apiService.serverConfig.webBaseUrl
// TODO: MBL-1159: This will take URL parameters, as defined in the ticket, for PKCE
return base
}
}

0 comments on commit 856d19c

Please sign in to comment.