Fixed up some bugs in auth, moved authorize function into auth.go