Updated login and relogin logic to use core data.