From 9d4e77baa202582ec11791fee486bb4659b8cb04 Mon Sep 17 00:00:00 2001 From: Rita Zerrizuela Date: Wed, 8 Dec 2021 18:38:11 -0300 Subject: [PATCH] Lowercase the `PasswordlessType` enum cases --- Auth0/Auth0Authentication.swift | 2 +- Auth0/Authentication.swift | 42 ++++++++++++++--------------- Auth0Tests/AuthenticationSpec.swift | 6 ++--- V2_MIGRATION_GUIDE.md | 11 ++++++++ 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/Auth0/Auth0Authentication.swift b/Auth0/Auth0Authentication.swift index 6644190e..91c6e0eb 100644 --- a/Auth0/Auth0Authentication.swift +++ b/Auth0/Auth0Authentication.swift @@ -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 } diff --git a/Auth0/Authentication.swift b/Auth0/Authentication.swift index 508792d7..d833a86d 100644 --- a/Auth0/Authentication.swift +++ b/Auth0/Authentication.swift @@ -4,6 +4,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. @@ -379,7 +394,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. @@ -407,7 +422,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. @@ -520,21 +535,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 { /** @@ -861,12 +861,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 { + func startPasswordless(email: String, type: PasswordlessType = .code, connection: String = "email", parameters: [String: Any] = [:]) -> Request { return self.startPasswordless(email: email, type: type, connection: connection, parameters: parameters) } @@ -891,12 +891,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 { + func startPasswordless(phoneNumber: String, type: PasswordlessType = .code, connection: String = "sms") -> Request { return self.startPasswordless(phoneNumber: phoneNumber, type: type, connection: connection) } diff --git a/Auth0Tests/AuthenticationSpec.swift b/Auth0Tests/AuthenticationSpec.swift index ac0366af..c9219727 100644 --- a/Auth0Tests/AuthenticationSpec.swift +++ b/Auth0Tests/AuthenticationSpec.swift @@ -786,7 +786,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() } @@ -797,7 +797,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() } @@ -807,7 +807,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() } diff --git a/V2_MIGRATION_GUIDE.md b/V2_MIGRATION_GUIDE.md index 9437afa6..4e23c3c5 100644 --- a/V2_MIGRATION_GUIDE.md +++ b/V2_MIGRATION_GUIDE.md @@ -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) @@ -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