Skip to content

Commit

Permalink
Merge branch 'v2' into fix_signup_policy_single_screen
Browse files Browse the repository at this point in the history
  • Loading branch information
hzalaz authored Jan 16, 2017
2 parents 74b6f64 + 5b6dfad commit 1c09993
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 75 deletions.
8 changes: 4 additions & 4 deletions Lock/CredentialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import UIKit

public class CredentialView: UIView, Form {
class CredentialView: UIView, Form {

var identityField: InputField
var passwordField: InputField
Expand Down Expand Up @@ -50,18 +50,18 @@ public class CredentialView: UIView, Form {

// MARK: - Initialisers

public convenience init() {
convenience init() {
self.init(frame: CGRect.zero)
}

required override public init(frame: CGRect) {
required override init(frame: CGRect) {
self.identityField = InputField()
self.passwordField = InputField()
super.init(frame: frame)
self.layoutForm()
}

public required init?(coder aDecoder: NSCoder) {
required init?(coder aDecoder: NSCoder) {
self.identityField = InputField()
self.passwordField = InputField()
super.init(coder: aDecoder)
Expand Down
4 changes: 3 additions & 1 deletion Lock/DatabaseForgotPasswordPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DatabaseForgotPasswordPresenter: Presentable, Loggable {

var view: View {
let email = self.interactor.validEmail ? self.interactor.email : nil
let view = DatabaseForgotPasswordView(email: email, options: options)
let view = DatabaseForgotPasswordView(email: email)
let form = view.form

view.form?.onValueChange = { input in
Expand Down Expand Up @@ -73,6 +73,8 @@ class DatabaseForgotPasswordPresenter: Presentable, Loggable {
} else {
let message = "We've just sent you an email to reset your password".i18n(key: "com.auth0.lock.database.forgot.success.message", comment: "forgot password email sent")
self.messagePresenter?.showSuccess(message)
guard self.options.allow.contains(.Login) else { return }
self.navigator.navigate(.root)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lock/DatabaseForgotPasswordView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DatabaseForgotPasswordView: UIView, View {
weak var form: Form?
weak var primaryButton: PrimaryButton?

init(email: String?, options: Options) {
init(email: String?) {
let primaryButton = PrimaryButton()
let forgotView = SingleInputView()
let center = UILayoutGuide()
Expand Down
12 changes: 6 additions & 6 deletions Lock/DatabaseModeSwitcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

import UIKit

public class DatabaseModeSwitcher: UIView {
class DatabaseModeSwitcher: UIView {

weak var segmentedControl: UISegmentedControl?

var onSelectionChange: (DatabaseModeSwitcher) -> () = { _ in }

public enum Mode: Int {
enum Mode: Int {
case login = 0
case signup

Expand Down Expand Up @@ -57,16 +57,16 @@ public class DatabaseModeSwitcher: UIView {

// MARK: - Initialisers

public convenience init() {
convenience init() {
self.init(frame: CGRect.zero)
}

required override public init(frame: CGRect) {
required override init(frame: CGRect) {
super.init(frame: frame)
self.layoutSwitcher()
}

public required init?(coder aDecoder: NSCoder) {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.layoutSwitcher()
}
Expand Down Expand Up @@ -109,7 +109,7 @@ public class DatabaseModeSwitcher: UIView {
self.selected = .login
}

public override var intrinsicContentSize : CGSize {
override var intrinsicContentSize : CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: 55)
}

Expand Down
8 changes: 2 additions & 6 deletions Lock/DatabasePresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,13 @@ class DatabasePresenter: Presentable, Loggable {
}
}

// Enterprise Authentication
if let connection = self.enterpriseInteractor?.connection {
// Credential Auth
if self.options.enterpriseConnectionUsingActiveAuth.contains(connection.name) {
self.navigator.navigate(.enterpriseActiveAuth(connection: connection))
} else {
// OAuth
self.enterpriseInteractor?.login(errorHandler)
}
} else {
// Database Authentication
self.authenticator.login(errorHandler)
}

Expand Down Expand Up @@ -164,7 +160,7 @@ class DatabasePresenter: Presentable, Loggable {
guard createError != nil || loginError != nil else {
if !self.options.loginAfterSignup {
let message = "Thanks for signing up.".i18n(key: "com.auth0.lock.database.signup.success.message", comment: "User signed up")
if let databaseView = self.databaseView {
if let databaseView = self.databaseView, self.options.allow.contains(.Login) {
self.showLogin(inView: databaseView, identifier: self.creator.identifier)
}
self.messagePresenter?.showSuccess(message)
Expand Down Expand Up @@ -224,7 +220,7 @@ class DatabasePresenter: Presentable, Loggable {
guard let attr = attribute else { return }
do {
try self.authenticator.update(attr, value: input.text)
// Check for Entperise domain match in login view

if self.enterpriseInteractor?.matchDomain(input.text) != nil, let mode = self.databaseView?.switcher?.selected, mode == .login {
try self.enterpriseInteractor?.updateEmail(input.text)
self.logger.verbose("Enterprise connection detected: \(self.enterpriseInteractor?.connection)")
Expand Down
2 changes: 1 addition & 1 deletion Lock/EnterpriseActiveAuthPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class EnterpriseActiveAuthPresenter: Presentable, Loggable {
identifier = username
}

let view = EnterpriseActiveAuthView(identifer: identifier, identifierAttribute: self.interactor.identifierAttribute, options: self.options)
let view = EnterpriseActiveAuthView(identifer: identifier, identifierAttribute: self.interactor.identifierAttribute)
let form = view.form
view.ssoBar?.title = self.interactor.connection.domains.first

Expand Down
2 changes: 1 addition & 1 deletion Lock/EnterpriseActiveAuthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EnterpriseActiveAuthView: UIView, View {

private weak var container: UIStackView?

init(identifer: String?, identifierAttribute:UserAttribute, options: Options) {
init(identifer: String?, identifierAttribute:UserAttribute) {
let primaryButton = PrimaryButton()
let credentialView = CredentialView()
let container = UIStackView()
Expand Down
2 changes: 0 additions & 2 deletions Lock/EnterpriseDomainInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ struct EnterpriseDomainInteractor: HRDAuthenticatable {
self.connections = connections.enterprise
self.authenticator = authentication

// Single Enterprise, defaulting connection
if self.connections.count == 1 && connections.oauth2.isEmpty && connections.database == nil {
self.connection = self.connections.first
}
Expand All @@ -57,7 +56,6 @@ struct EnterpriseDomainInteractor: HRDAuthenticatable {
throw error
}
validEmail = true

connection = matchDomain(value)
}

Expand Down
7 changes: 0 additions & 7 deletions Lock/EnterpriseDomainPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class EnterpriseDomainPresenter: Presentable, Loggable {
var customLogger: Logger?
var user: User
var options: Options

// Social connections
var authPresenter: AuthPresenter?

init(interactor: EnterpriseDomainInteractor, navigator: Navigable, user: User, options: Options) {
Expand All @@ -46,7 +44,6 @@ class EnterpriseDomainPresenter: Presentable, Loggable {
let email = self.interactor.validEmail ? self.interactor.email : nil
let authCollectionView = self.authPresenter?.newViewToEmbed(withInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0), isLogin: true)

// Single Enterprise Domain
if let enterpriseButton = EnterpriseButton(forConnections: interactor.connections, customStyle: [:], isLogin: true, onAction: {
self.interactor.login { error in
Queue.main.async {
Expand All @@ -57,7 +54,6 @@ class EnterpriseDomainPresenter: Presentable, Loggable {
self.logger.debug("Enterprise authenticator launched")
}
}

}}) {
let view = EnterpriseDomainView(authButton: enterpriseButton, authCollectionView: authCollectionView)
return view
Expand Down Expand Up @@ -86,7 +82,6 @@ class EnterpriseDomainPresenter: Presentable, Loggable {
}

let action = { [weak form] (button: PrimaryButton) in
// Check for credential auth
if let connection = self.interactor.connection, self.options.enterpriseConnectionUsingActiveAuth.contains(connection.name) {
guard self.navigator?.navigate(.enterpriseActiveAuth(connection: connection)) == nil else { return }
}
Expand All @@ -106,9 +101,7 @@ class EnterpriseDomainPresenter: Presentable, Loggable {
self.logger.debug("Enterprise authenticator launched")
}
}

}

}

view.primaryButton?.onPress = action
Expand Down
2 changes: 1 addition & 1 deletion Lock/EnterpriseDomainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private func strutView(withHeight height: CGFloat = 50) -> UIView {
return view
}

public class EnterpriseSingleInputView : SingleInputView {
class EnterpriseSingleInputView : SingleInputView {

public override var intrinsicContentSize : CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: 50)
Expand Down
10 changes: 5 additions & 5 deletions Lock/InfoBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import UIKit

public class InfoBarView: UIView {
class InfoBarView: UIView {

weak var container: UIView?
weak var iconView: UIImageView?
Expand All @@ -38,16 +38,16 @@ public class InfoBarView: UIView {
}
}

public convenience init() {
convenience init() {
self.init(frame: CGRect.zero)
}

required override public init(frame: CGRect) {
required override init(frame: CGRect) {
super.init(frame: frame)
self.layoutHeader()
}

public required init?(coder aDecoder: NSCoder) {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.layoutHeader()
}
Expand Down Expand Up @@ -91,7 +91,7 @@ public class InfoBarView: UIView {
self.iconView?.tintColor = UIColor ( red: 0.5725, green: 0.5804, blue: 0.5843, alpha: 1.0 )
}

public override var intrinsicContentSize : CGSize {
override var intrinsicContentSize : CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: 35)
}

Expand Down
18 changes: 9 additions & 9 deletions Lock/InputField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import UIKit

public class InputField: UIView, UITextFieldDelegate {
class InputField: UIView, UITextFieldDelegate {

weak var containerView: UIView?
weak var textField: UITextField?
Expand Down Expand Up @@ -77,16 +77,16 @@ public class InputField: UIView, UITextFieldDelegate {

// MARK: - Initialisers

public convenience init() {
convenience init() {
self.init(frame: CGRect.zero)
}

required override public init(frame: CGRect) {
required override init(frame: CGRect) {
super.init(frame: frame)
self.layoutField()
}

public required init?(coder aDecoder: NSCoder) {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.layoutField()
}
Expand Down Expand Up @@ -183,7 +183,7 @@ public class InputField: UIView, UITextFieldDelegate {
self.containerView?.layer.borderColor = State.valid.color.cgColor
}

public override var intrinsicContentSize : CGSize {
override var intrinsicContentSize : CGSize {
return CGSize(width: 230, height: 50)
}

Expand Down Expand Up @@ -221,15 +221,15 @@ public class InputField: UIView, UITextFieldDelegate {
}
}

public func textFieldDidBeginEditing(_ textField: UITextField) {
func textFieldDidBeginEditing(_ textField: UITextField) {
self.onBeginEditing(self)
}

public func textFieldDidEndEditing(_ textField: UITextField) {
func textFieldDidEndEditing(_ textField: UITextField) {
self.onEndEditing(self)
}

public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
self.onReturn(self)
if let field = self.nextField?.textField {
Queue.main.async {
Expand All @@ -248,7 +248,7 @@ public class InputField: UIView, UITextFieldDelegate {
}

// MARK: - Types
public enum InputType {
enum InputType {
case email
case username
case emailOrUsername
Expand Down
10 changes: 5 additions & 5 deletions Lock/MessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import UIKit

public class MessageView: UIView {
class MessageView: UIView {

weak var messageLabel: UILabel?

Expand All @@ -42,7 +42,7 @@ public class MessageView: UIView {
}
}

public enum Flavor {
enum Flavor {
case success
case failure

Expand All @@ -60,16 +60,16 @@ public class MessageView: UIView {
}
}

required override public init(frame: CGRect) {
required override init(frame: CGRect) {
super.init(frame: frame)
self.layoutMessage()
}

public convenience init() {
convenience init() {
self.init(frame: CGRect.zero)
}

public required convenience init?(coder aDecoder: NSCoder) {
required convenience init?(coder aDecoder: NSCoder) {
self.init(frame: CGRect.zero)
}

Expand Down
1 change: 0 additions & 1 deletion Lock/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public protocol Options {
var customSignupFields: [CustomTextField] { get }
var loginAfterSignup: Bool { get }

// Enterprise
var activeDirectoryEmailAsUsername: Bool { get }
var enterpriseConnectionUsingActiveAuth: [String] { get }

Expand Down
Loading

0 comments on commit 1c09993

Please sign in to comment.