Last active
February 5, 2018 14:45
-
-
Save nanlabsweb/30e29ec832123351cb06b58edacee34b to your computer and use it in GitHub Desktop.
Authentication flow logic is delegated to a dedicated module.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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