Skip to content

Instantly share code, notes, and snippets.

@adrianhall
Created April 18, 2018 19:51
Show Gist options
  • Save adrianhall/a37a76312137d4629956a7a6cb192516 to your computer and use it in GitHub Desktop.
Save adrianhall/a37a76312137d4629956a7a6cb192516 to your computer and use it in GitHub Desktop.
The handleLogin() method
/**
* Handles the login event
*/
private fun handleLogin() {
val username = loginform_username.getContent()
val password = loginform_password.getContent()
Log.d(TAG, "handleLogin - username = $username, password = $password")
/**
* This is very "identityManager" specific code, so we check for the various
* bits of support. The "Mock" version will just
*/
when (identityManager) {
is MockIdentityManager -> {
Log.i(TAG, "Invoking Mock User Authentication")
val user = User()
user.username = username
userIsAuthenticated(user)
}
is AWSIdentityManager -> {
Log.i(TAG, "Invoking Amazon Cognito User Authentication")
thread(start = true) {
val cognitoUser = (identityManager as AWSIdentityManager).userPool.currentUser
cognitoUser.getSession(this)
}
}
else -> {
throw RuntimeException("Unknown IdentityManager implementation")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment