refactor agent/admin authentication check; prevent server error if registration attempt of existing username is made and add error message to registration page