Move code to login controller