Refactor User Authentication