Abstract login clode and improve ux