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

Change the casing of PasswordlessType cases #580

Merged
merged 2 commits into from
Dec 9, 2021
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 Auth0/Auth0Authentication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ struct Auth0Authentication: Authentication {
"send": type.rawValue,
"client_id": self.clientId
]
if case .WebLink = type, !parameters.isEmpty {
if case .webLink = type, !parameters.isEmpty {
payload["authParams"] = parameters
}

Expand Down
42 changes: 21 additions & 21 deletions Auth0/Authentication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ import Foundation
*/
public typealias DatabaseUser = (email: String, username: String?, verified: Bool)

/**
Types of passwordless authentication.

- code: Simple OTP code sent by email or sms.
- webLink: Regular Web HTTP link (Web only, uses redirect).
- iOSLink: Universal Link.
- androidLink: Android App Link.
*/
public enum PasswordlessType: String {
case code = "code"
case webLink = "link"
case iOSLink = "link_ios"
case androidLink = "link_android"
}

/**
Auth endpoints of Auth0.

Expand Down Expand Up @@ -435,7 +450,7 @@ public protocol Authentication: Trackable, Loggable {

- Parameters:
- email: Email where to send the code or link.
- type: Type of passwordless authentication. By default is 'code'.
- type: Type of passwordless authentication. By default is `code`.
- connection: Name of the passwordless connection. By default is 'email'.
- Returns: A request.
- Requires: Passwordless OTP Grant `http://auth0.com/oauth/grant-type/passwordless/otp`. Check [our documentation](https://auth0.com/docs/configure/applications/application-grant-types) for more info and how to enable it.
Expand Down Expand Up @@ -463,7 +478,7 @@ public protocol Authentication: Trackable, Loggable {

- Parameters:
- phoneNumber: Phone number where to send the sms with code or link.
- type: Type of passwordless authentication. By default is 'code'.
- type: Type of passwordless authentication. By default is `code`.
- connection: Name of the passwordless connection. By default is 'sms'.
- Returns: A request.
- Requires: Passwordless OTP Grant `http://auth0.com/oauth/grant-type/passwordless/otp`. Check [our documentation](https://auth0.com/docs/configure/applications/application-grant-types) for more info and how to enable it.
Expand Down Expand Up @@ -591,21 +606,6 @@ public protocol Authentication: Trackable, Loggable {

}

/**
Types of passwordless authentication

- Code: Simple OTP code sent by email or sms
- WebLink: Regular Web HTTP link (Web only, uses redirect)
- iOSLink: Universal Link
- AndroidLink: Android App Link
*/
public enum PasswordlessType: String {
case Code = "code"
case WebLink = "link"
case iOSLink = "link_ios"
case AndroidLink = "link_android"
}

public extension Authentication {

/**
Expand Down Expand Up @@ -954,12 +954,12 @@ public extension Authentication {

- Parameters:
- email: Email where to send the code or link.
- type: Type of passwordless authentication. By default is 'code'.
- type: Type of passwordless authentication. By default is `code`.
- connection: Name of the passwordless connection. By default is 'email'.
- Returns: A request.
- Requires: Passwordless OTP Grant `http://auth0.com/oauth/grant-type/passwordless/otp`. Check [our documentation](https://auth0.com/docs/configure/applications/application-grant-types) for more info and how to enable it.
*/
func startPasswordless(email: String, type: PasswordlessType = .Code, connection: String = "email", parameters: [String: Any] = [:]) -> Request<Void, AuthenticationError> {
func startPasswordless(email: String, type: PasswordlessType = .code, connection: String = "email", parameters: [String: Any] = [:]) -> Request<Void, AuthenticationError> {
return self.startPasswordless(email: email, type: type, connection: connection, parameters: parameters)
}

Expand All @@ -984,12 +984,12 @@ public extension Authentication {

- Parameters:
- phoneNumber: Phone number where to send the sms with code or link.
- type: Type of passwordless authentication. By default is 'code'.
- type: Type of passwordless authentication. By default is `code`.
- connection: Name of the passwordless connection. By default is 'sms'.
- Returns: A request.
- Requires: Passwordless OTP Grant `http://auth0.com/oauth/grant-type/passwordless/otp`. Check [our documentation](https://auth0.com/docs/configure/applications/application-grant-types) for more info and how to enable it.
*/
func startPasswordless(phoneNumber: String, type: PasswordlessType = .Code, connection: String = "sms") -> Request<Void, AuthenticationError> {
func startPasswordless(phoneNumber: String, type: PasswordlessType = .code, connection: String = "sms") -> Request<Void, AuthenticationError> {
return self.startPasswordless(phoneNumber: phoneNumber, type: type, connection: connection)
}

Expand Down
6 changes: 3 additions & 3 deletions Auth0Tests/AuthenticationSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ class AuthenticationSpec: QuickSpec {
let params = ["scope": "openid"]
stub(condition: isPasswordless(Domain) && hasAtLeast(["email": SupportAtAuth0]) && hasObjectAttribute("authParams", value: params)) { _ in return passwordless(SupportAtAuth0, verified: true) }.name = "email passwordless web link with parameters"
waitUntil(timeout: Timeout) { done in
auth.startPasswordless(email: SupportAtAuth0, type: .WebLink, parameters: params).start { result in
auth.startPasswordless(email: SupportAtAuth0, type: .webLink, parameters: params).start { result in
expect(result).to(beSuccessful())
done()
}
Expand All @@ -795,7 +795,7 @@ class AuthenticationSpec: QuickSpec {
let params = ["scope": "openid"]
stub(condition: isPasswordless(Domain) && hasAllOf(["email": SupportAtAuth0, "connection": "email", "client_id": ClientId, "send": "code"])) { _ in return passwordless(SupportAtAuth0, verified: true) }.name = "email passwordless without parameters"
waitUntil(timeout: Timeout) { done in
auth.startPasswordless(email: SupportAtAuth0, type: .Code, parameters: params).start { result in
auth.startPasswordless(email: SupportAtAuth0, type: .code, parameters: params).start { result in
expect(result).to(beSuccessful())
done()
}
Expand All @@ -805,7 +805,7 @@ class AuthenticationSpec: QuickSpec {
it("should not add params attr if they are empty") {
stub(condition: isPasswordless(Domain) && hasAllOf(["email": SupportAtAuth0, "connection": "email", "client_id": ClientId, "send": "code"])) { _ in return passwordless(SupportAtAuth0, verified: true) }.name = "email passwordless without parameters"
waitUntil(timeout: Timeout) { done in
auth.startPasswordless(email: SupportAtAuth0, type: .Code, parameters: [:]).start { result in
auth.startPasswordless(email: SupportAtAuth0, type: .code, parameters: [:]).start { result in
expect(result).to(beSuccessful())
done()
}
Expand Down
11 changes: 11 additions & 0 deletions V2_MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ As expected with a major release, Auth0.swift v2 contains breaking changes. Plea
* [Extensions](#extensions)
- [Types changed](#types-changed)
- [Type properties changed](#type-properties-changed)
* [`PasswordlessType` enum](#passwordlesstype-enum)
* [`AuthenticationError` struct](#authenticationerror-struct)
* [`ManagementError` struct](#managementerror-struct)
* [`WebAuthError` struct](#webautherror-struct)
Expand Down Expand Up @@ -214,6 +215,16 @@ The `a0_url(_:)` method is no longer public.

## Type properties changed

### `PasswordlessType` enum

#### Cases renamed

The following cases were lowercased, as per the naming convention of Swift 3+:

- `Code` -> `code`
- `WebLink` -> `webLink`
- `AndroidLink` -> `androidLink`

### `AuthenticationError` struct

#### Properties removed
Expand Down