Hi,
I’m pretty new to coding, so this may be a dumb question. I’m trying to create a register and login page. I’ve been able to register users and have been able to log them in. However, when a wrong username or password is entered, the app crashes. Any help would be appreciated, I’m about ready to pull out all my hair.
I’ve provided the coding below. The first part is the registration (that’s working) and the second part is where I’m having issues. Thanks!
let backendless = Backendless.sharedInstance()
let user: BackendlessUser = BackendlessUser()
user.email = self.email.text
user.password = self.password.text
_ = backendless.userService.registering(user)
print("User has been registered (SYNC): \registeredUser")
self.activityIndicator.stopAnimating()
UIApplication.sharedApplication().endIgnoringInteractionEvents()
- } else {
let backendless = Backendless.sharedInstance()
let user = backendless.userService.login(email.text, password: password.text)
print("User has been logged in (SYNC): \(user)")
self.activityIndicator.stopAnimating()
UIApplication.sharedApplication().endIgnoringInteractionEvents()
if user != nil {
// Logged in
} else {
displayAlert(“Login Attempt Failed”, message: “Please retry email and password”)
}
}
}