Skip to content

Commit

Permalink
added login form password size validation
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsrk committed Dec 26, 2022
1 parent b0abaeb commit baf8654
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .idea/codestream.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 17 additions & 14 deletions app/src/main/java/com/example/buspayment/screens/LoginScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,25 @@ fun LoginForm(navController: NavController) {
onClick = {
error = ""
if (email.isNotEmpty() && pass.isNotEmpty()) {
isLoading = true
Firebase.auth.signInWithEmailAndPassword(email, pass).addOnCompleteListener {
if (it.isSuccessful) {
isLoading = false
navController.navigate(Screens.Home.route) {
popUpTo(0)
if (pass.length < 6) {
isLoading = true
Firebase.auth.signInWithEmailAndPassword(email, pass).addOnCompleteListener {
if (it.isSuccessful) {
isLoading = false
navController.navigate(Screens.Home.route) {
popUpTo(0)
}
val user = User(0, "", email)
mUserViewModel.deleteUsers()
mUserViewModel.addUser(user)
Credentials().setEmail(email)
Toast.makeText(context, "Successfully logged in", Toast.LENGTH_LONG).show()
} else {
error = "Wrong username or password"
isLoading = false
}
val user = User(0, "", email)
mUserViewModel.deleteUsers()
mUserViewModel.addUser(user)
Credentials().setEmail(email)
Toast.makeText(context, "Successfully logged in", Toast.LENGTH_LONG).show()
} else {
error = "Wrong username or password"
isLoading = false
}

}
} else {
error = "Fill all the fields"
Expand Down

0 comments on commit baf8654

Please sign in to comment.