Inlined auth functions into model.