Path: blob/master/src/packages/conat/hub/api/util.ts
1452 views
export const authFirst = ({ args, account_id, project_id }) => {1if (args[0] == null) {2args[0] = {} as any;3}4if (account_id) {5args[0].account_id = account_id;6} else if (project_id) {7args[0].project_id = project_id;8}9return args;10};1112export const noAuth = ({ args }) => args;1314// make no changes, except throw error if account_id not set (i.e., user not signed in)15export const requireAccount = ({ args, account_id }) => {16if (!account_id) {17throw Error("user must be signed in");18}19return args;20};2122export const authFirstRequireAccount = async ({ args, account_id }) => {23if (args[0] == null) {24args[0] = {} as any;25}26if (!account_id) {27throw Error("user must be signed in");28}29args[0].account_id = account_id;30return args;31};32333435