Skip to content

Commit

Permalink
Chore Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
cocojoe committed Sep 14, 2018
1 parent f27aea7 commit 2bb9962
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 24 deletions.
18 changes: 6 additions & 12 deletions App/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,28 @@ class ViewController: UIViewController {
}

@IBAction func startOAuth2(_ sender: Any) {
let auth0 = Auth0.webAuth()
auth0
Auth0.webAuth()
.logging(enabled: true)
.start(onAuth)
}

@IBAction func startGoogleOAuth2(_ sender: Any) {
let auth0 = Auth0.webAuth()
auth0
Auth0.webAuth()
.logging(enabled: true)
.connection("google-oauth2")
.start(onAuth)
}

@IBAction func startTokenGoogleOAuth2(_ sender: Any) {
let auth0 = Auth0.webAuth()
auth0
Auth0.webAuth()
.logging(enabled: true)
.connection("google-oauth2")
.responseType([.token])
.start(onAuth)
}

@IBAction func startIDTokenGoogleOAuth2(_ sender: Any) {
let auth0 = Auth0.webAuth()
auth0
Auth0.webAuth()
.logging(enabled: true)
.connection("google-oauth2")
.responseType([.idToken])
Expand All @@ -69,8 +65,7 @@ class ViewController: UIViewController {
}

@IBAction func startTokenIDTokenGoogleOAuth2(_ sender: Any) {
let auth0 = Auth0.webAuth()
auth0
Auth0.webAuth()
.logging(enabled: true)
.connection("google-oauth2")
.responseType([.token, .idToken])
Expand All @@ -79,8 +74,7 @@ class ViewController: UIViewController {
}

@IBAction func startCodeIDTokenGoogleOAuth2(_ sender: Any) {
let auth0 = Auth0.webAuth()
auth0
Auth0.webAuth()
.logging(enabled: true)
.connection("google-oauth2")
.scope("read:entity")
Expand Down
2 changes: 1 addition & 1 deletion Auth0/AuthSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AuthSession: NSObject, AuthTransaction {
- returns: `true` if the url completed (successfuly or not) this session, `false` otherwise
*/
func resume(_ url: URL, options: [OpenURLOptionsKey: Any] = [:]) -> Bool {
func resume(_ url: URL, options: [A0URLOptionsKey: Any] = [:]) -> Bool {
self.logger?.trace(url: url, source: "iOS Safari")
guard url.absoluteString.lowercased().hasPrefix(self.redirectURL.absoluteString.lowercased()) else { return false }

Expand Down
2 changes: 1 addition & 1 deletion Auth0/AuthTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public protocol AuthTransaction {
- parameter options: options recieved in the openUrl method of the `AppDelegate`
- returns: if the url was expected and properly formatted otherwise it will return false.
*/
func resume(_ url: URL, options: [OpenURLOptionsKey: Any]) -> Bool
func resume(_ url: URL, options: [A0URLOptionsKey: Any]) -> Bool

/**
Terminates the transaction and reports back that it was cancelled.
Expand Down
2 changes: 1 addition & 1 deletion Auth0/SafariAuthenticationCallback.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SafariAuthenticationSessionCallback: AuthTransaction {
self.authSession?.start()
}

func resume(_ url: URL, options: [OpenURLOptionsKey: Any]) -> Bool {
func resume(_ url: URL, options: [A0URLOptionsKey: Any]) -> Bool {
self.callback(true)
return true
}
Expand Down
6 changes: 0 additions & 6 deletions Auth0/SafariWebAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
import UIKit
import SafariServices

#if swift(>=4.2)
public typealias OpenURLOptionsKey = UIApplication.OpenURLOptionsKey
#else
public typealias OpenURLOptionsKey = UIApplicationOpenURLOptionsKey
#endif

class SafariWebAuth: WebAuth {

fileprivate static let NoBundleIdentifier = "com.auth0.this-is-no-bundle"
Expand Down
2 changes: 1 addition & 1 deletion Auth0/TransactionStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TransactionStore {

private(set) var current: AuthTransaction?

func resume(_ url: URL, options: [OpenURLOptionsKey: Any]) -> Bool {
func resume(_ url: URL, options: [A0URLOptionsKey: Any]) -> Bool {
let resumed = self.current?.resume(url, options: options) ?? false
if resumed {
self.current = nil
Expand Down
8 changes: 7 additions & 1 deletion Auth0/WebAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

import UIKit

#if swift(>=4.2)
public typealias A0URLOptionsKey = UIApplication.OpenURLOptionsKey
#else
public typealias A0URLOptionsKey = UIApplicationOpenURLOptionsKey
#endif

/**
Auth0 iOS component for authenticating with web-based flow
Expand Down Expand Up @@ -78,7 +84,7 @@ public func webAuth(clientId: String, domain: String) -> WebAuth {
- returns: if the url was handled by an on going session or not.
*/
public func resumeAuth(_ url: URL, options: [OpenURLOptionsKey: Any]) -> Bool {
public func resumeAuth(_ url: URL, options: [A0URLOptionsKey: Any]) -> Bool {
return TransactionStore.shared.resume(url, options: options)
}

Expand Down
2 changes: 1 addition & 1 deletion Auth0/_ObjectiveWebAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class _ObjectiveOAuth2: NSObject {
- returns: if the url was handled by an on going session or not.
*/
@objc(resumeAuthWithURL:options:)
public static func resume(_ url: URL, options: [OpenURLOptionsKey: Any]) -> Bool {
public static func resume(_ url: URL, options: [A0URLOptionsKey: Any]) -> Bool {
return TransactionStore.shared.resume(url, options: options)
}

Expand Down

0 comments on commit 2bb9962

Please sign in to comment.