oidc: flatten the export list
This commit is contained in:
+14
-15
@@ -6,13 +6,12 @@ exports = module.exports = {
|
||||
revokeByUserId,
|
||||
getUserByAuthCode,
|
||||
consumeAuthCode,
|
||||
clients: {
|
||||
add: clientsAdd,
|
||||
get: clientsGet,
|
||||
del: clientsDel,
|
||||
update: clientsUpdate,
|
||||
list: clientsList
|
||||
}
|
||||
|
||||
addClient,
|
||||
getClient,
|
||||
delClient,
|
||||
updateClient,
|
||||
listClients
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
@@ -66,7 +65,7 @@ function postProcess(result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
async function clientsAdd(id, data) {
|
||||
async function addClient(id, data) {
|
||||
assert.strictEqual(typeof id, 'string');
|
||||
assert.strictEqual(typeof data.secret, 'string');
|
||||
assert.strictEqual(typeof data.loginRedirectUri, 'string');
|
||||
@@ -82,7 +81,7 @@ async function clientsAdd(id, data) {
|
||||
if (error) throw error;
|
||||
}
|
||||
|
||||
async function clientsGet(id) {
|
||||
async function getClient(id) {
|
||||
assert.strictEqual(typeof id, 'string');
|
||||
|
||||
if (id === tokens.ID_WEBADMIN) {
|
||||
@@ -112,7 +111,7 @@ async function clientsGet(id) {
|
||||
return postProcess(result[0]);
|
||||
}
|
||||
|
||||
async function clientsUpdate(id, data) {
|
||||
async function updateClient(id, data) {
|
||||
assert.strictEqual(typeof id, 'string');
|
||||
assert.strictEqual(typeof data.loginRedirectUri, 'string');
|
||||
assert.strictEqual(typeof data.name, 'string');
|
||||
@@ -123,14 +122,14 @@ async function clientsUpdate(id, data) {
|
||||
if (result.affectedRows !== 1) throw new BoxError(BoxError.NOT_FOUND, 'client not found');
|
||||
}
|
||||
|
||||
async function clientsDel(id) {
|
||||
async function delClient(id) {
|
||||
assert.strictEqual(typeof id, 'string');
|
||||
|
||||
const result = await database.query(`DELETE FROM ${OIDC_CLIENTS_TABLE_NAME} WHERE id = ?`, [ id ]);
|
||||
if (result.affectedRows !== 1) throw new BoxError(BoxError.NOT_FOUND, 'client not found');
|
||||
}
|
||||
|
||||
async function clientsList() {
|
||||
async function listClients() {
|
||||
const results = await database.query(`SELECT * FROM ${OIDC_CLIENTS_TABLE_NAME} ORDER BY name ASC`, []);
|
||||
|
||||
results.forEach(postProcess);
|
||||
@@ -295,7 +294,7 @@ class CloudronAdapter {
|
||||
debug(`[${this.name}] find: ${id}`);
|
||||
|
||||
if (this.name === 'Client') {
|
||||
const [error, client] = await safe(clientsGet(id));
|
||||
const [error, client] = await safe(getClient(id));
|
||||
if (error) {
|
||||
debug('find: error getting client', error);
|
||||
return null;
|
||||
@@ -474,7 +473,7 @@ function renderInteractionPage(provider) {
|
||||
try {
|
||||
const { uid, prompt, params, session } = await provider.interactionDetails(req, res);
|
||||
|
||||
const client = await clientsGet(params.client_id);
|
||||
const client = await getClient(params.client_id);
|
||||
|
||||
let app = null;
|
||||
if (client.appId) app = await apps.get(client.appId);
|
||||
@@ -635,7 +634,7 @@ function interactionConfirm(provider) {
|
||||
|
||||
assert.equal(name, 'consent');
|
||||
|
||||
const client = await clientsGet(params.client_id);
|
||||
const client = await getClient(params.client_id);
|
||||
const user = await users.get(accountId);
|
||||
|
||||
// Check if user has access to the app if client refers to an app
|
||||
|
||||
Reference in New Issue
Block a user