Refactoring of authentication.
Refactoring of authentication.