Auth checks refactoring

Refactoring auth checks using a single check_auth() function. This improves the module readability and maintainability