Auth refactoring