Better handling of login workflow