diff --git a/Lock/DatabaseOnlyView.swift b/Lock/DatabaseOnlyView.swift index a283afb30..e28668858 100644 --- a/Lock/DatabaseOnlyView.swift +++ b/Lock/DatabaseOnlyView.swift @@ -129,7 +129,7 @@ class DatabaseOnlyView: UIView, DatabaseView { } // swiftlint:disable:next function_parameter_count - func showSignUp(withUsername showUsername: Bool, username: String?, email: String?, authCollectionView: AuthCollectionView? = nil, additionalFields: [CustomTextField], passwordPolicyValidator: PasswordPolicyValidator? = nil, showPassswordManager: Bool, showPassword: Bool) { + func showSignUp(withUsername showUsername: Bool, username: String?, email: String?, authCollectionView: AuthCollectionView? = nil, additionalFields: [CustomTextField], passwordPolicyValidator: PasswordPolicyValidator? = nil, showPassswordManager: Bool, showPassword: Bool, showTerms: Bool) { let form = SignUpView(additionalFields: additionalFields) form.showUsername = showUsername form.emailField.text = email @@ -139,7 +139,7 @@ class DatabaseOnlyView: UIView, DatabaseView { primaryButton?.title = "SIGN UP".i18n(key: "com.auth0.lock.submit.signup.title", comment: "Signup Button title") layoutInStack(form, authCollectionView: authCollectionView) - self.layoutSecondaryButton(true) + self.layoutSecondaryButton(showTerms) self.form = form self.identityField = showUsername ? form.usernameField : form.emailField diff --git a/Lock/DatabasePresenter.swift b/Lock/DatabasePresenter.swift index 59ceee4ca..9899b781a 100644 --- a/Lock/DatabasePresenter.swift +++ b/Lock/DatabasePresenter.swift @@ -175,7 +175,7 @@ class DatabasePresenter: Presentable, Loggable { let passwordPolicyValidator = interactor?.passwordValidator as? PasswordPolicyValidator self.currentScreen = .signup interactor?.user.reset() - view.showSignUp(withUsername: self.database.requiresUsername, username: username, email: email, authCollectionView: authCollectionView, additionalFields: self.options.customSignupFields, passwordPolicyValidator: passwordPolicyValidator, showPassswordManager: self.passwordManager.available, showPassword: self.options.allowShowPassword) + view.showSignUp(withUsername: self.database.requiresUsername, username: username, email: email, authCollectionView: authCollectionView, additionalFields: self.options.customSignupFields, passwordPolicyValidator: passwordPolicyValidator, showPassswordManager: self.passwordManager.available, showPassword: self.options.allowShowPassword, showTerms: options.showTerms || options.mustAcceptTerms) let form = view.form view.form?.onValueChange = self.handleInput diff --git a/Lock/DatabaseView.swift b/Lock/DatabaseView.swift index 1cdec5e0f..ba048c1d3 100644 --- a/Lock/DatabaseView.swift +++ b/Lock/DatabaseView.swift @@ -39,5 +39,5 @@ protocol DatabaseView: class, View { func showLogin(withIdentifierStyle style: DatabaseIdentifierStyle, identifier: String?, authCollectionView: AuthCollectionView?, showPassswordManager: Bool, showPassword: Bool) // swiftlint:disable:next function_parameter_count - func showSignUp(withUsername showUsername: Bool, username: String?, email: String?, authCollectionView: AuthCollectionView?, additionalFields: [CustomTextField], passwordPolicyValidator: PasswordPolicyValidator?, showPassswordManager: Bool, showPassword: Bool) + func showSignUp(withUsername showUsername: Bool, username: String?, email: String?, authCollectionView: AuthCollectionView?, additionalFields: [CustomTextField], passwordPolicyValidator: PasswordPolicyValidator?, showPassswordManager: Bool, showPassword: Bool, showTerms: Bool) } diff --git a/Lock/LockOptions.swift b/Lock/LockOptions.swift index 634c8acfc..0e9654c42 100644 --- a/Lock/LockOptions.swift +++ b/Lock/LockOptions.swift @@ -29,6 +29,7 @@ struct LockOptions: OptionBuildable { var privacyPolicyURL: URL = URL(string: "https://auth0.com/privacy")! var supportURL: URL? var mustAcceptTerms: Bool = false + var showTerms: Bool = true var logLevel: LoggerLevel = .off var loggerOutput: LoggerOutput? var logHttpRequest: Bool = false diff --git a/Lock/OptionBuildable.swift b/Lock/OptionBuildable.swift index d06af3bf9..6d5b91112 100644 --- a/Lock/OptionBuildable.swift +++ b/Lock/OptionBuildable.swift @@ -39,9 +39,12 @@ public protocol OptionBuildable: Options { /// Support page url that will be displayed (Inside Safari) when an unrecoverable error occurs and the user taps the "Contact Support" button in the error screen. var supportURL: URL? { get set } - /// Whether the user needs to accept the terms before sign up or not. + /// Whether the user needs to accept the terms before sign up or not. By default is false. var mustAcceptTerms: Bool { get set } + /// Whether the terms should be shown on the signup screen. By default is true. + var showTerms: Bool { get set } + /// Log level for Lock. By default is `Off`. var logLevel: LoggerLevel { get set } diff --git a/Lock/Options.swift b/Lock/Options.swift index b4dcede43..311b9a627 100644 --- a/Lock/Options.swift +++ b/Lock/Options.swift @@ -29,6 +29,7 @@ public protocol Options { var privacyPolicyURL: URL { get } var supportURL: URL? { get } var mustAcceptTerms: Bool { get } + var showTerms: Bool { get } var logLevel: LoggerLevel { get } var loggerOutput: LoggerOutput? { get } diff --git a/LockTests/OptionsSpec.swift b/LockTests/OptionsSpec.swift index c30865b4b..498278c26 100644 --- a/LockTests/OptionsSpec.swift +++ b/LockTests/OptionsSpec.swift @@ -128,6 +128,10 @@ class OptionsSpec: QuickSpec { it("should have configurationBaseURL as nil") { expect(options.configurationBaseURL).to(beNil()) } + + it("should have showTerms as enabled") { + expect(options.showTerms) == true + } } describe("validation") { @@ -181,7 +185,7 @@ class OptionsSpec: QuickSpec { options.audience = "https://myapi.com" expect(options.validate()).to(beNil()) } - + context("passwordless") { it("should fail setting audience in passwordless mode") { diff --git a/LockTests/Presenters/AuthPresenterSpec.swift b/LockTests/Presenters/AuthPresenterSpec.swift index d2ce08e6c..7f272c9df 100644 --- a/LockTests/Presenters/AuthPresenterSpec.swift +++ b/LockTests/Presenters/AuthPresenterSpec.swift @@ -93,7 +93,7 @@ class AuthPresenterSpec: QuickSpec { var view: AuthCollectionView! beforeEach { - view = presenter.view as! AuthCollectionView + view = presenter.view as? AuthCollectionView } diff --git a/LockTests/Presenters/DatabaseForgotPasswordPresenterSpec.swift b/LockTests/Presenters/DatabaseForgotPasswordPresenterSpec.swift index 6f0bcd3bc..453fd207d 100644 --- a/LockTests/Presenters/DatabaseForgotPasswordPresenterSpec.swift +++ b/LockTests/Presenters/DatabaseForgotPasswordPresenterSpec.swift @@ -46,7 +46,7 @@ class DatabaseForgotPasswordPresenterSpec: QuickSpec { connections.database(name: connection, requiresUsername: true) presenter = DatabaseForgotPasswordPresenter(interactor: interactor, connections: connections, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! DatabaseForgotPasswordView + view = presenter.view as? DatabaseForgotPasswordView } it("should use valid email") { @@ -200,7 +200,7 @@ class DatabaseForgotPasswordPresenterSpec: QuickSpec { options.allow = .ResetPassword presenter = DatabaseForgotPasswordPresenter(interactor: interactor, connections: connections, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! DatabaseForgotPasswordView + view = presenter.view as? DatabaseForgotPasswordView } it("should not show global success message") { @@ -216,7 +216,7 @@ class DatabaseForgotPasswordPresenterSpec: QuickSpec { options.autoClose = false presenter = DatabaseForgotPasswordPresenter(interactor: interactor, connections: connections, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! DatabaseForgotPasswordView + view = presenter.view as? DatabaseForgotPasswordView interactor.onRequest = { return nil @@ -246,7 +246,7 @@ class DatabaseForgotPasswordPresenterSpec: QuickSpec { navigator.route = .forgotPassword presenter = DatabaseForgotPasswordPresenter(interactor: interactor, connections: connections, navigator: navigator, options: options) - view = presenter.view as! DatabaseForgotPasswordView + view = presenter.view as? DatabaseForgotPasswordView let button = view.primaryButton! interactor.onRequest = { diff --git a/LockTests/Presenters/DatabasePresenterSpec.swift b/LockTests/Presenters/DatabasePresenterSpec.swift index dfe3cfc0f..3ac6acf3f 100644 --- a/LockTests/Presenters/DatabasePresenterSpec.swift +++ b/LockTests/Presenters/DatabasePresenterSpec.swift @@ -54,7 +54,7 @@ class DatabasePresenterSpec: QuickSpec { navigator = MockNavigator() presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView } describe("auth buttons") { @@ -151,7 +151,7 @@ class DatabasePresenterSpec: QuickSpec { var options = LockOptions() options.allow = [.Login, .Signup] presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView expect(view.switcher).toNot(beNil()) } @@ -159,7 +159,7 @@ class DatabasePresenterSpec: QuickSpec { var options = LockOptions() options.allow = [.Login] presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView expect(view.switcher).to(beNil()) } @@ -167,7 +167,7 @@ class DatabasePresenterSpec: QuickSpec { var options = LockOptions() options.allow = [.Login] presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView expect(view.secondaryButton).to(beNil()) } @@ -176,7 +176,7 @@ class DatabasePresenterSpec: QuickSpec { options.allow = [.Login] options.initialScreen = .login presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView expect(view.form as? CredentialView).toNot(beNil()) } @@ -184,7 +184,7 @@ class DatabasePresenterSpec: QuickSpec { var options = LockOptions() options.allow = [.Signup] presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView expect(view.form as? SignUpView).toNot(beNil()) } @@ -193,7 +193,7 @@ class DatabasePresenterSpec: QuickSpec { options.allow = [.Signup, .Login] options.initialScreen = .signup presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView expect(view.form as? SignUpView).toNot(beNil()) } @@ -201,7 +201,26 @@ class DatabasePresenterSpec: QuickSpec { var options = LockOptions() options.allow = [.Signup] presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView + expect(view.secondaryButton).toNot(beNil()) + } + + it("should hide terms button in signup") { + var options = LockOptions() + options.allow = [.Signup] + options.showTerms = false + presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) + view = presenter.view as? DatabaseOnlyView + expect(view.secondaryButton).to(beNil()) + } + + it("should show terms button in signup when terms disabled but must accept terms is enabled") { + var options = LockOptions() + options.allow = [.Signup] + options.showTerms = false + options.mustAcceptTerms = true + presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) + view = presenter.view as? DatabaseOnlyView expect(view.secondaryButton).toNot(beNil()) } @@ -238,7 +257,7 @@ class DatabasePresenterSpec: QuickSpec { beforeEach { presenter.passwordManager = passwordManager - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView } it("should show password manager button") { @@ -247,7 +266,7 @@ class DatabasePresenterSpec: QuickSpec { it("should not show password manager when disabled") { presenter.passwordManager.enabled = false - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView expect(view.passwordManagerButton).to(beNil()) } @@ -418,7 +437,7 @@ class DatabasePresenterSpec: QuickSpec { options.autoClose = false presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView interactor.onLogin = { return nil } @@ -437,7 +456,7 @@ class DatabasePresenterSpec: QuickSpec { username = nil password = nil presenter.passwordManager = passwordManager - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView view.switcher?.selected = .signup view.switcher?.onSelectionChange(view.switcher!) presenter.passwordManager.onUpdate = { username = $0; password = $1 } @@ -539,7 +558,7 @@ class DatabasePresenterSpec: QuickSpec { beforeEach { presenter.passwordManager = passwordManager - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView view.switcher?.selected = .signup view.switcher?.onSelectionChange(view.switcher!) } @@ -673,7 +692,7 @@ class DatabasePresenterSpec: QuickSpec { beforeEach { options.mustAcceptTerms = true presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: false), navigator: navigator, options: options) - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView view.switcher?.selected = .signup view.switcher?.onSelectionChange(view.switcher!) } @@ -709,7 +728,7 @@ class DatabasePresenterSpec: QuickSpec { it("should switch to login on success") { presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView let button = view.primaryButton! interactor.onSignUp = { @@ -722,7 +741,7 @@ class DatabasePresenterSpec: QuickSpec { it("should remain on signup on success") { options.allow = .Signup presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView let button = view.primaryButton! interactor.onSignUp = { @@ -740,7 +759,7 @@ class DatabasePresenterSpec: QuickSpec { options.autoClose = false presenter = DatabasePresenter(authenticator: interactor, creator: interactor, connection: DatabaseConnection(name: connection, requiresUsername: true), navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView } it("should show no success message") { @@ -763,7 +782,7 @@ class DatabasePresenterSpec: QuickSpec { username = nil password = nil presenter.passwordManager = passwordManager - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView view.switcher?.selected = .signup view.switcher?.onSelectionChange(view.switcher!) presenter.passwordManager.onUpdate = { username = $0; password = $1 } @@ -808,7 +827,7 @@ class DatabasePresenterSpec: QuickSpec { enterpriseInteractor = EnterpriseDomainInteractor(connections: connections, user: user, authentication: oauth2) presenter.enterpriseInteractor = enterpriseInteractor - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView } it("should modify display with enterprise changes") { @@ -898,7 +917,7 @@ class DatabasePresenterSpec: QuickSpec { enterpriseInteractor = EnterpriseDomainInteractor(connections: connections, user: user, authentication: oauth2) presenter.enterpriseInteractor = enterpriseInteractor - view = presenter.view as! DatabaseOnlyView + view = presenter.view as? DatabaseOnlyView let input = mockInput(.email, value: "user@valid.com") view.form?.onValueChange(input) diff --git a/LockTests/Presenters/EnterpriseActiveAuthPresenterSpec.swift b/LockTests/Presenters/EnterpriseActiveAuthPresenterSpec.swift index cea371d56..62fc9d393 100644 --- a/LockTests/Presenters/EnterpriseActiveAuthPresenterSpec.swift +++ b/LockTests/Presenters/EnterpriseActiveAuthPresenterSpec.swift @@ -48,7 +48,7 @@ class EnterpriseActiveAuthPresenterSpec: QuickSpec { presenter = EnterpriseActiveAuthPresenter(interactor: interactor, options: options, domain: "test.com") presenter.messagePresenter = messagePresenter - view = presenter.view as! EnterpriseActiveAuthView + view = presenter.view as? EnterpriseActiveAuthView } describe("init") { @@ -155,7 +155,7 @@ class EnterpriseActiveAuthPresenterSpec: QuickSpec { presenter = EnterpriseActiveAuthPresenter(interactor: interactor, options: options, domain: "test.com") presenter.messagePresenter = messagePresenter - view = presenter.view as! EnterpriseActiveAuthView + view = presenter.view as? EnterpriseActiveAuthView } it("should update email if value is valid") { @@ -193,7 +193,7 @@ class EnterpriseActiveAuthPresenterSpec: QuickSpec { presenter = EnterpriseActiveAuthPresenter(interactor: interactor, options: options, domain: "test.com") presenter.messagePresenter = messagePresenter - view = presenter.view as! EnterpriseActiveAuthView + view = presenter.view as? EnterpriseActiveAuthView } it("should not trigger action with nil button") { diff --git a/LockTests/Presenters/EnterpriseDomainPresenterSpec.swift b/LockTests/Presenters/EnterpriseDomainPresenterSpec.swift index 1f20fc299..c5c80a26d 100644 --- a/LockTests/Presenters/EnterpriseDomainPresenterSpec.swift +++ b/LockTests/Presenters/EnterpriseDomainPresenterSpec.swift @@ -56,7 +56,7 @@ class EnterpriseDomainPresenterSpec: QuickSpec { interactor = EnterpriseDomainInteractor(connections: connections, user: user, authentication: oauth2) presenter = EnterpriseDomainPresenter(interactor: interactor, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! EnterpriseDomainView + view = presenter.view as? EnterpriseDomainView } describe("init") { @@ -200,7 +200,7 @@ class EnterpriseDomainPresenterSpec: QuickSpec { presenter = EnterpriseDomainPresenter(interactor: interactor, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! EnterpriseDomainView + view = presenter.view as? EnterpriseDomainView } it("should navigate to enterprise password presenter") { diff --git a/LockTests/Presenters/MultifactorPresenterSpec.swift b/LockTests/Presenters/MultifactorPresenterSpec.swift index 168147649..8654fe802 100644 --- a/LockTests/Presenters/MultifactorPresenterSpec.swift +++ b/LockTests/Presenters/MultifactorPresenterSpec.swift @@ -43,7 +43,7 @@ class MultifactorPresenterSpec: QuickSpec { connection = DatabaseConnection(name: "my-connection", requiresUsername: true) presenter = MultifactorPresenter(interactor: interactor, connection: connection, navigator: navigator) presenter.messagePresenter = messagePresenter - view = presenter.view as! MultifactorCodeView + view = presenter.view as? MultifactorCodeView } it("should have button title") { diff --git a/LockTests/Presenters/PasswordlessPresenterSpec.swift b/LockTests/Presenters/PasswordlessPresenterSpec.swift index 9f942d7d8..8e554b383 100644 --- a/LockTests/Presenters/PasswordlessPresenterSpec.swift +++ b/LockTests/Presenters/PasswordlessPresenterSpec.swift @@ -60,7 +60,7 @@ class PasswordlessPresenterSpec: QuickSpec { interactor = PasswordlessInteractor(connection: connection, authentication: authentication, dispatcher: dispatcher, user: user, options: options, passwordlessActivity: passwordlessActivity) presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } describe("request screen") { @@ -105,7 +105,7 @@ class PasswordlessPresenterSpec: QuickSpec { interactor.onRequest = { return nil } presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } it("should trigger action on return of field") { @@ -157,7 +157,7 @@ class PasswordlessPresenterSpec: QuickSpec { interactor.onRequest = { return nil } presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } it("should trigger action on return of field") { @@ -195,7 +195,7 @@ class PasswordlessPresenterSpec: QuickSpec { beforeEach { presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options, screen: screen) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } it("should show code screen") { @@ -238,7 +238,7 @@ class PasswordlessPresenterSpec: QuickSpec { interactor.onRequest = { return nil } presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options, screen: screen) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } it("should trigger action on return of field") { @@ -272,7 +272,7 @@ class PasswordlessPresenterSpec: QuickSpec { beforeEach { presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options, screen: screen) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } it("should show code screen") { @@ -300,7 +300,7 @@ class PasswordlessPresenterSpec: QuickSpec { interactor = PasswordlessInteractor(connection: connection, authentication: authentication, dispatcher: dispatcher, user: user, options: options, passwordlessActivity: passwordlessActivity) presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } describe("request screen") { @@ -361,7 +361,7 @@ class PasswordlessPresenterSpec: QuickSpec { interactor.onRequest = { return nil } presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } it("should trigger action on return of field") { @@ -411,7 +411,7 @@ class PasswordlessPresenterSpec: QuickSpec { interactor.onRequest = { return nil } presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } it("should trigger action on return of field") { @@ -449,7 +449,7 @@ class PasswordlessPresenterSpec: QuickSpec { beforeEach { presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options, screen: screen) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } it("should show code screen") { @@ -492,7 +492,7 @@ class PasswordlessPresenterSpec: QuickSpec { interactor.onRequest = { return nil } presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options, screen: screen) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } it("should trigger action on return of field") { @@ -526,7 +526,7 @@ class PasswordlessPresenterSpec: QuickSpec { beforeEach { presenter = PasswordlessPresenter(interactor: interactor, connection: connection, navigator: navigator, options: options, screen: screen) presenter.messagePresenter = messagePresenter - view = presenter.view as! PasswordlessView + view = presenter.view as? PasswordlessView } it("should show code screen") { diff --git a/LockTests/Utils/Mocks.swift b/LockTests/Utils/Mocks.swift index 0e674d507..ea7b6b2f1 100644 --- a/LockTests/Utils/Mocks.swift +++ b/LockTests/Utils/Mocks.swift @@ -254,7 +254,7 @@ class MockAuthentication: Authentication { } func tokenInfo(token: String) -> Request { - return self.userInfo(token: token) + return self.authentication.userInfo(token: token) } func resetPassword(email: String, connection: String) -> Request { @@ -270,7 +270,7 @@ class MockAuthentication: Authentication { } func login(withOTP otp: String, mfaToken: String) -> Request { - return self.login(withOTP: otp, mfaToken: mfaToken) + return self.authentication.login(withOTP: otp, mfaToken: mfaToken) } func tokenExchange(withCode code: String, codeVerifier: String, redirectURI: String) -> Request { @@ -278,7 +278,7 @@ class MockAuthentication: Authentication { } func renew(withRefreshToken refreshToken: String) -> Request { - return self.renew(withRefreshToken: refreshToken) + return self.authentication.renew(withRefreshToken: refreshToken) } func login(usernameOrEmail username: String, password: String, multifactorCode: String?, connection: String, scope: String, parameters: [String : Any]) -> Request { @@ -294,11 +294,11 @@ class MockAuthentication: Authentication { } func revoke(refreshToken: String) -> Request { - return self.revoke(refreshToken: refreshToken) + return self.authentication.revoke(refreshToken: refreshToken) } func userInfo(withAccessToken accessToken: String) -> Request { - return self.userInfo(withAccessToken: accessToken) + return self.authentication.userInfo(withAccessToken: accessToken) } } diff --git a/README.md b/README.md index 02ccd2cd0..552603bc9 100644 --- a/README.md +++ b/README.md @@ -321,7 +321,7 @@ By default Lock will use Auth0's [Terms of Service](https://auth0.com/terms) and #### Must accept Terms of Service -Database connection will require explicit acceptance of terms of service +Database connection will require explicit acceptance of terms of service. ```swift .withOptions { @@ -329,6 +329,17 @@ Database connection will require explicit acceptance of terms of service } ``` +#### Show Terms of Service + +Database connection will display the Terms & Service dialog. Default is `true`. +Note: Terms will always be shown if the `mustAcceptTerms` flag has been enabled. + +```swift +.withOptions { + $0.showTerms = true +} +``` + #### Logging * **logLevel**: By default this is `.off`, *Syslog* logging levels are supported.