Move auth logic into a service