Skip to content

Commit

Permalink
Rename resumeAuth method
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket committed Nov 2, 2021
1 parent 6ebf91c commit 8aaa773
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Auth0/ASCallbackTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#if WEB_AUTH_PLATFORM
import AuthenticationServices

final class ASCallbackTransaction: BaseCallbackTransaction, ASWebAuthenticationPresentationContextProviding {
final class ASCallbackTransaction: BaseCallbackTransaction {

init(url: URL, schemeURL: URL, callback: @escaping (Bool) -> Void) {
super.init(callback: callback)
Expand Down
6 changes: 3 additions & 3 deletions Auth0/BaseTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ class BaseTransaction: NSObject, AuthTransaction {
authSession = nil
}

func handleUrl(_ url: URL) -> Bool {
func resume(_ url: URL) -> Bool {
self.logger?.trace(url: url, source: "iOS Safari")
if self.resumeAuth(url) {
if self.handleURL(url) {
authSession?.cancel()
authSession = nil
return true
}
return false
}

private func resumeAuth(_ url: URL) -> Bool {
private func handleURL(_ url: URL) -> Bool {
guard url.absoluteString.lowercased().hasPrefix(self.redirectURL.absoluteString.lowercased()) else { return false }
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
self.callback(.failure(AuthenticationError(string: url.absoluteString, statusCode: 200)))
Expand Down
6 changes: 3 additions & 3 deletions Auth0Tests/BaseTransactionSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ class BaseTransactionSpec: QuickSpec {
context("handle url") {
it("should handle url") {
let url = URL(string: "https://samples.auth0.com/callback?code=\(code)&state=state")!
expect(transaction.handleUrl(url)) == true
expect(transaction.resume(url)) == true
expect(result).toEventually(haveCredentials())
}

it("should handle url with error") {
let url = URL(string: "https://samples.auth0.com/callback?error=error&error_description=description&state=state")!
expect(transaction.handleUrl(url)) == true
expect(transaction.resume(url)) == true
expect(result).toEventually(haveAuthenticationError(code: "error", description: "description"))
}

it("should fail to handle url without state") {
let url = URL(string: "https://samples.auth0.com/callback?code=\(code)")!
expect(transaction.handleUrl(url)) == false
expect(transaction.resume(url)) == false
}
}

Expand Down

0 comments on commit 8aaa773

Please sign in to comment.