Move auth loggin code