Skip to content

Instantly share code, notes, and snippets.

@Yoloabdo
Last active June 4, 2020 20:03
Show Gist options
  • Select an option

  • Save Yoloabdo/912a18dc44235824177b5b05e0c6f588 to your computer and use it in GitHub Desktop.

Select an option

Save Yoloabdo/912a18dc44235824177b5b05e0c6f588 to your computer and use it in GitHub Desktop.
typealias AuthenticationViewSource = UIViewController & AuthServiceDelegate
class UserAuthenticator {
private weak var source: AuthenticationViewSource?
private var service: AuthService?
init(_ viewController: AuthenticationViewSource) {
self.source = viewController
}
func authenticate(_ type: PreferredAuthMethod) {
guard let source = source else { return }
service = type.getService(source: source, delegate: source)
service?.authenticate()
}
func deAuthenticate(type: PreferredAuthMethod) {
guard let source = source else { return }
service = type.getService(source: source, delegate: source)
service?.deAuthenticate()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment