centralized auth logic