Skip to content

Commit fef779c

Browse files
authoredMar 27, 2017
Merge pull request #104 from auth0/added-nativeauth-available
Method to check native auth availability for provider in the device
2 parents dc4aed6 + c4a2ee2 commit fef779c

6 files changed

+25
-7
lines changed
 

‎.ruby-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruby-2.2.1
1+
ruby-2.3.1

‎.swiftlint.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type_body_length:
1818
- 400 # error
1919
type_name:
2020
min_length: 3 # only warning
21-
variable_name:
21+
identifier_name:
2222
min_length: # only min_length
2323
warning: 3 # only error
2424
excluded: # No regex support available for this
@@ -27,4 +27,7 @@ variable_name:
2727
- a0_isManagementError
2828
- a0_fragmentValues
2929
- a0_queryValues
30+
- Code
31+
- WebLink
32+
- AndroidLink
3033
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit)

‎Auth0/AuthProvider.swift

+15
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,23 @@ import UIKit
3535
...
3636
return transaction
3737
}
38+
39+
static func isAvailable() -> Bool {
40+
return true
41+
}
42+
3843
```
3944
*/
4045
public protocol AuthProvider {
4146
func login(withConnection connection: String, scope: String, parameters: [String: Any]) -> NativeAuthTransaction
47+
48+
/**
49+
Determine if the Auth method used by the Provider is available on the device.
50+
e.g. If using a Twitter Auth provider it should check the presence of a Twitter account on the device.
51+
52+
If a Auth is performed on a provider that returns `false` the transaction will fail with an error.
53+
54+
- returns: Bool if the AuthProvider is available on the device
55+
*/
56+
static func isAvailable() -> Bool
4257
}

‎Auth0/Handlers.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func databaseUser(from response: Response<AuthenticationError>, callback: Reques
6565

6666
func noBody(from response: Response<AuthenticationError>, callback: Request<Void, AuthenticationError>.Callback) {
6767
do {
68-
let _ = try response.result()
68+
_ = try response.result()
6969
callback(.success(result: ()))
7070
} catch let error {
7171
callback(.failure(error: error))

‎Auth0/SafariSession.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class SafariSession: NSObject, AuthTransaction {
6666
}
6767
var items = self.handler.values(fromComponents: components)
6868
guard has(state: self.state, inItems: items) else { return false }
69-
if let _ = items["error"] {
69+
if items["error"] != nil {
7070
self.finish(.failure(error: AuthenticationError(info: items, statusCode: 0)))
7171
} else {
7272
self.handler.credentials(from: items, callback: self.finish)

‎Auth0/_ObjectiveWebAuth.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class _ObjectiveOAuth2: NSObject {
3939
}
4040

4141
public func addParameters(_ parameters: [String: String]) {
42-
let _ = self.webAuth.parameters(parameters)
42+
_ = self.webAuth.parameters(parameters)
4343
}
4444

4545
/**
@@ -64,7 +64,7 @@ public class _ObjectiveOAuth2: NSObject {
6464
public var connection: String? {
6565
set {
6666
if let value = newValue {
67-
let _ = self.webAuth.connection(value)
67+
_ = self.webAuth.connection(value)
6868
}
6969
}
7070
get {
@@ -78,7 +78,7 @@ public class _ObjectiveOAuth2: NSObject {
7878
public var scope: String? {
7979
set {
8080
if let value = newValue {
81-
let _ = self.webAuth.scope(value)
81+
_ = self.webAuth.scope(value)
8282
}
8383
}
8484
get {

0 commit comments

Comments
 (0)
Please sign in to comment.