Partial move of auth logic to new file