mod: extract the login procedure.