refactor some auth stuff out to share between pages