Merge "Refactor extract code to function in auth.py"