Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset UI if the login fails. #9

Open
OwenLaRosa opened this issue Nov 9, 2018 · 5 comments
Open

Reset UI if the login fails. #9

OwenLaRosa opened this issue Nov 9, 2018 · 5 comments
Labels
moviemanagerchallenge Task for "Improve the Movie Manager" Challenge

Comments

@OwenLaRosa
Copy link
Contributor

In lesson 7, we added an activity indicator to the login view. The view appears and starts spinning when the login process begins, and stops spinning and disappears when the login is complete.

But what happens if the login doesn't complete? Try an incorrect username/password or modifying the API key. After dismissing the alert, the spinner keeps spinning. You'll also notice that the text fields can't be edited, nor can you press any of the buttons.

We already know where to add code for when the login fails. To fix this issue, try calling setLoggingIn() in the appropriate places to ensure UI changes appropriately to match the "logging in" state.

@OwenLaRosa OwenLaRosa added the moviemanagerchallenge Task for "Improve the Movie Manager" Challenge label Nov 9, 2018
@ShoLynx
Copy link

ShoLynx commented Jan 3, 2019

Even to one new to coding, this issue was pretty simple to fix. I simply added 'setLoggingIn(false)' after both the if and else blocks within the handleLoginResponse method. This should terminate the activity indicator and re-enable the locked fields and buttons in the LoginViewController.

@AsmaHero
Copy link

setLoggingIn(false) in handle login response inside else block helped me to enable buttons again to try another username and password to get login information correct

@2k-joker
Copy link

2k-joker commented Jun 5, 2021

I think calling setLoggingIn(false) inside the completionHandler for the UIAlertAction is the proper way of handling this. That way, resetting the login page is triggered when the user clicks the OK button when the showLoginFailure alert pops up 🤷🏾

@EdwardPhaniOS
Copy link

My solution:
func showLoginFailure(message: String) {
....
setLoggingIn(false)
}

@joabm
Copy link

joabm commented Aug 29, 2022

did the same thing @EdwardPhaniOS. I also added that to the loginViaWebsiteTapped method if the getRequestToken response was successful because the logginIn method was hanging after going to the browser and coming back again.

@IBAction func loginViaWebsiteTapped() {
setLoggingIn(true)
TMDBClient.getRequestToken { (success, error) in
if success {
......................
self.setLoggingIn(false)
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moviemanagerchallenge Task for "Improve the Movie Manager" Challenge
Projects
None yet
Development

No branches or pull requests

6 participants