modified validate function in auth.py