We already have this code in `auth.py`, you should move this to `util.py` and use it in both places.