Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method to check native auth availability for provider in the device #104

Merged
merged 3 commits into from
Mar 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.2.1
ruby-2.3.1
5 changes: 4 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type_body_length:
- 400 # error
type_name:
min_length: 3 # only warning
variable_name:
identifier_name:
min_length: # only min_length
warning: 3 # only error
excluded: # No regex support available for this
Expand All @@ -27,4 +27,7 @@ variable_name:
- a0_isManagementError
- a0_fragmentValues
- a0_queryValues
- Code
- WebLink
- AndroidLink
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit)
15 changes: 15 additions & 0 deletions Auth0/AuthProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,23 @@ import UIKit
...
return transaction
}

static func isAvailable() -> Bool {
return true
}

```
*/
public protocol AuthProvider {
func login(withConnection connection: String, scope: String, parameters: [String: Any]) -> NativeAuthTransaction

/**
Determine if the Auth method used by the Provider is available on the device.
e.g. If using a Twitter Auth provider it should check the presence of a Twitter account on the device.

If a Auth is performed on a provider that returns `false` the transaction will fail with an error.

- returns: Bool if the AuthProvider is available on the device
*/
static func isAvailable() -> Bool
}
2 changes: 1 addition & 1 deletion Auth0/Handlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func databaseUser(from response: Response<AuthenticationError>, callback: Reques

func noBody(from response: Response<AuthenticationError>, callback: Request<Void, AuthenticationError>.Callback) {
do {
let _ = try response.result()
_ = try response.result()
callback(.success(result: ()))
} catch let error {
callback(.failure(error: error))
Expand Down
2 changes: 1 addition & 1 deletion Auth0/SafariSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class SafariSession: NSObject, AuthTransaction {
}
var items = self.handler.values(fromComponents: components)
guard has(state: self.state, inItems: items) else { return false }
if let _ = items["error"] {
if items["error"] != nil {
self.finish(.failure(error: AuthenticationError(info: items, statusCode: 0)))
} else {
self.handler.credentials(from: items, callback: self.finish)
Expand Down
6 changes: 3 additions & 3 deletions Auth0/_ObjectiveWebAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class _ObjectiveOAuth2: NSObject {
}

public func addParameters(_ parameters: [String: String]) {
let _ = self.webAuth.parameters(parameters)
_ = self.webAuth.parameters(parameters)
}

/**
Expand All @@ -64,7 +64,7 @@ public class _ObjectiveOAuth2: NSObject {
public var connection: String? {
set {
if let value = newValue {
let _ = self.webAuth.connection(value)
_ = self.webAuth.connection(value)
}
}
get {
Expand All @@ -78,7 +78,7 @@ public class _ObjectiveOAuth2: NSObject {
public var scope: String? {
set {
if let value = newValue {
let _ = self.webAuth.scope(value)
_ = self.webAuth.scope(value)
}
}
get {
Expand Down