budibase/packages/server/utilities/budibaseApi.js

41 lines
800 B
JavaScript
Raw Normal View History

2019-06-07 15:18:10 +02:00
const crypto = require("../nodeCrypto");
2019-06-14 11:05:46 +02:00
const {getAppApis} = require("budibase-core");
2019-06-07 15:18:10 +02:00
module.exports.getApisWithFullAccess = async (datastore) => {
const bb = await getAppApis(
datastore,
null, null, null,
crypto
);
bb.withFullAccess();
return bb;
};
module.exports.getApisForUser = async (datastore, username, password) => {
const bb = await getAppApis(
datastore,
null, null, null,
crypto
);
await bb.authenticateAs(username, password);
return bb;
}
2019-06-14 18:01:01 +02:00
module.exports.getApisForSession = async (datastore, session) => {
2019-06-14 11:05:46 +02:00
const user = JSON.parse(session.user_json);
const bb = await getAppApis(
datastore,
null, null, null,
crypto
);
bb.asUser(user);
return bb;
}