 		}
 		
 		// Replace current root view controller with Safari view controller for login
-		let loginVC = LoginViewController(url: url)
-		loginVC.replacedRootViewController = window.rootViewController
+		let loginVC = createLoginViewController(url: url)
+		guard let loginViewControllerable = loginVC as? LoginViewControllerable else {
+			throw SalesforceError.invalidity(message: "No valid LoginViewController!")
+		}
+		
+		loginViewControllerable.replacedRootViewController = window.rootViewController
 		window.rootViewController = loginVC
 	}
 	


public typealias LoginResult = Alamofire.Result<AuthData>

fileprivate final class LoginViewController: SFSafariViewController {
	// Hold reference to the view controller that's temporarily replaced by the login view controller
	var replacedRootViewController: UIViewController?
}

public protocol LoginDelegate {
	var window: UIWindow? { get }
	func login(url: URL) throws
}

// MARK: - Extension

	
	public var loggingIn: Bool {
		get {
			if let _ = window?.rootViewController as? LoginViewControllerable {
				return true
			}
			else {
