centralise authentication & propagation of login phase in login.js