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

Cleanup API #27

Merged
merged 4 commits into from
Jun 20, 2016
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
4 changes: 2 additions & 2 deletions Auth0/Auth0.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public func authentication(clientId clientId: String, domain: String, session: N
- returns: Auth0 Authentication API
- important: Calling this method without a valid `Auth0.plist` will crash your application
*/
public func authentication(session: NSURLSession = .sharedSession()) -> Authentication {
public func authentication(session session: NSURLSession = .sharedSession()) -> Authentication {
let values = plistValues()!
return authentication(clientId: values.clientId, domain: values.domain, session: session)
}
Expand Down Expand Up @@ -194,7 +194,7 @@ public func users(token token: String, domain: String, session: NSURLSession = .
- note: By default all logging is **disabled**
- important: Logging should be turned on/off **before** making request to Auth0 for the flag to take effect.
*/
public func enableLogging(enabled: Bool = true) {
public func enableLogging(enabled enabled: Bool = true) {
Auth0Logger.sharedInstance.logger = enabled ? DefaultLogger() : nil
}

Expand Down
121 changes: 53 additions & 68 deletions Auth0/Authentication/Authentication.swift

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public class _ObjectiveAuthenticationAPI: NSObject {
@objc(loginWithUsername:password:connection:scope:parameters:callback:)
public func login(username: String, password: String, connection: String, scope: String, parameters: [String: AnyObject]?, callback: (NSError?, Credentials?) -> ()) {
self.authentication
.login(username, password: password, connection: connection, scope: scope, parameters: parameters ?? [:])
.login(usernameOrEmail: username, password: password, connection: connection, scope: scope, parameters: parameters ?? [:])
.start(handleResult(callback))
}

@objc(createUserWithEmail:username:password:connection:userMetadata:callback:)
public func createUser(email: String, username: String?, password: String, connection: String, userMetadata: [String: AnyObject]?, callback: (NSError?, [String: AnyObject]?) -> ()) {
self.authentication
.createUser(email, username: username, password: password, connection: connection, userMetadata: userMetadata)
.createUser(email: email, username: username, password: password, connection: connection, userMetadata: userMetadata)
.start { result in
switch result {
case .Success(let user):
Expand All @@ -68,14 +68,14 @@ public class _ObjectiveAuthenticationAPI: NSObject {
@objc(resetPasswordWithEmail:connection:callback:)
public func resetPassword(email: String, connection: String, callback: NSError? -> ()) {
self.authentication
.resetPassword(email, connection: connection)
.resetPassword(email: email, connection: connection)
.start(handleResult(callback))
}

@objc(signUpWithEmail:username:password:connection:userMetadata:scope:parameters:callback:)
public func signUp(email: String, username: String?, password: String, connection: String, userMetadata: [String: AnyObject]?, scope: String, parameters: [String: AnyObject]?, callback: (NSError?, Credentials?) -> ()) {
self.authentication
.signUp(email, username: username, password: password, connection: connection, userMetadata: userMetadata, scope: scope, parameters: parameters ?? [:])
.signUp(email: email, username: username, password: password, connection: connection, userMetadata: userMetadata, scope: scope, parameters: parameters ?? [:])
.start(handleResult(callback))
}

Expand Down Expand Up @@ -109,19 +109,19 @@ public class _ObjectiveAuthenticationAPI: NSObject {

@objc(tokenInfoFromToken:callback:)
public func tokenInfo(token: String, callback: (NSError?, UserProfile?) -> ()) {
self.authentication.tokenInfo(token).start(handleResult(callback))
self.authentication.tokenInfo(token: token).start(handleResult(callback))
}

@objc(userInfoWithToken:callback:)
public func userInfo(token: String, callback: (NSError?, UserProfile?) -> ()) {
self.authentication.userInfo(token).start(handleResult(callback))
self.authentication.userInfo(token: token).start(handleResult(callback))
}

@objc(loginSocialWithToken:connection:scope:parameters:callback:)
public func loginSocial(token: String, connection: String, scope: String, parameters: [String: AnyObject]?, callback: (NSError?, Credentials?) -> ()) {

self.authentication
.loginSocial(token, connection: connection, scope: scope, parameters: parameters ?? [:])
.loginSocial(token: token, connection: connection, scope: scope, parameters: parameters ?? [:])
.start(handleResult(callback))
}

Expand Down
4 changes: 2 additions & 2 deletions Auth0/Logger/_ObjectiveLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class _ObjectiveLogger: NSObject {
- important: Logging should be turned on/off **before** making request to Auth0 for the flag to take effect.
*/
public static func loggingEnabled() {
enableLogging(true)
enableLogging(enabled: true)
}

/**
Expand All @@ -42,6 +42,6 @@ public class _ObjectiveLogger: NSObject {
- important: Logging should be turned on/off **before** making request to Auth0 for the flag to take effect.
*/
public static func loggingEnabled(enabled: Bool) {
enableLogging(enabled)
enableLogging(enabled: enabled)
}
}
14 changes: 0 additions & 14 deletions Auth0/Management/Management.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,6 @@ public struct Management {

public typealias Object = [String: AnyObject]

/**
Types of errors that can be returned by Management API

- Response: the request was not successful and Auth0 returned an error response with the reeason it failed
- InvalidResponse: the response returned by Auth0 was not valid
- RequestFailed: the request failed
*/
public enum Error: ErrorType {
case Response(error: String, description: String, code: String, statusCode: Int)
case InvalidResponse(response: NSData?)
case RequestFailed(cause: ErrorType)
}


/**
Auth0 Users API v2

Expand Down
20 changes: 10 additions & 10 deletions Auth0/Management/Users.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public struct Users {

```
Auth0
.users(token, domain: "samples.auth0.com")
.users(token: token, domain: "samples.auth0.com")
.get(userId)
.start { print($0) }
```
Expand All @@ -45,7 +45,7 @@ public struct Users {

```
Auth0
.users(token, domain: "samples.auth0.com")
.users(token: token, domain: "samples.auth0.com")
.get(userId, fields: ["email", "user_id"])
.start { print($0) }
```
Expand All @@ -54,7 +54,7 @@ public struct Users {

```
Auth0
.users(token, domain: "samples.auth0.com")
.users(token token, domain: "samples.auth0.com")
.get(userId, fields: ["identities", "app_metadata"], include: false)
.start { print($0) }
```
Expand Down Expand Up @@ -112,7 +112,7 @@ public struct Users {

```
Auth0
.users(token, domain: "samples.auth0.com")
.users(token: token, domain: "samples.auth0.com")
.patch(userId, attributes: attributes)
.start { print($0) }
```
Expand All @@ -138,7 +138,7 @@ public struct Users {

```
Auth0
.users(token, domain: "samples.auth0.com")
.users(token: token, domain: "samples.auth0.com")
.patch(userId, userMetadata: ["first_name": "Juan", "last_name": "AuthZero"])
.start { print($0) }
```
Expand All @@ -160,7 +160,7 @@ public struct Users {

```
Auth0
.users(token, domain: "samples.auth0.com")
.users(token: token, domain: "samples.auth0.com")
.link(userId, withOtherUserToken: anotherToken)
.start { print($0) }
```
Expand All @@ -183,7 +183,7 @@ public struct Users {

```
Auth0
.users(token, domain: "samples.auth0.com")
.users(token: token, domain: "samples.auth0.com")
.link(userId, userId: anotherUserId, provider: "auth0", connectionId: "AConnectionID")
.start { print($0) }
```
Expand Down Expand Up @@ -218,8 +218,8 @@ public struct Users {

```
Auth0
.users(token, domain: "samples.auth0.com")
.unlink("an_idenitity_id", provider: "facebook", fromUserId: "a_user_identifier")
.users(token: token, domain: "samples.auth0.com")
.unlink(identityId: "an_idenitity_id", provider: "facebook", fromUserId: "a_user_identifier")
.start { print($0) }
```

Expand All @@ -232,7 +232,7 @@ public struct Users {
- seeAlso: [Link Accounts Guide](https://auth0.com/docs/link-accounts)
- important: The token must have the following scope `update:users`
*/
public func unlink(identityId: String, provider: String, fromUserId identifier: String) -> Request<[Management.Object], ManagementError> {
public func unlink(identityId identityId: String, provider: String, fromUserId identifier: String) -> Request<[Management.Object], ManagementError> {
let identityPath = "/api/v2/users/\(identifier)/identities/\(provider)/\(identityId)"
let url = components(self.management.url, path: identityPath).URL!
return Request(session: self.management.session, url: url, method: "DELETE", handle: self.management.managementObjects)
Expand Down
2 changes: 1 addition & 1 deletion Auth0/WebAuth/OAuth2Grant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct PKCE: OAuth2Grant {
return callback(.Failure(error: AuthenticationError(string: string)))
}
Authentication(clientId: clientId, url: url)
.exchangeCode(code, codeVerifier: verifier, redirectURI: redirectURL.absoluteString)
.tokenExchange(withCode: code, codeVerifier: verifier, redirectURI: redirectURL.absoluteString)
.start(callback)
}
}
Loading