added error checking and toasts to login()