Moved auth functions to separate file.