ReferenceError: UserErrors is not defined

I learned about authentication.onLogin(), so I moved the code to the Global Site page in EditorX and now it is running correctly, and not running twice.