Skip to content

Instantly share code, notes, and snippets.

@nanlabsweb
Last active February 5, 2018 14:45
Show Gist options
  • Save nanlabsweb/30e29ec832123351cb06b58edacee34b to your computer and use it in GitHub Desktop.
Save nanlabsweb/30e29ec832123351cb06b58edacee34b to your computer and use it in GitHub Desktop.
Authentication flow logic is delegated to a dedicated module.
class AuthViewModel(val authenticator: Authenticator, val context: Context) {
var providers = Arrays.asList(
AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build())
fun getActionIntent(): Intent {
return if (authenticator.isAuthenticated()) {
Intent(context, NewContentActivity::class.java)
} else {
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment