mirror of
https://gitlab.silvrtree.co.uk/martind2000/obrand-admin-server.git
synced 2025-01-11 06:15:08 +00:00
40a8337ab3
Also now serving api/pages as a list page and viewer.
36 lines
992 B
JavaScript
36 lines
992 B
JavaScript
'use strict';
|
|
var db = require('../units/db-connector').dbConnection;
|
|
var dbAccounts = require('../units/db-accounts')(db);
|
|
module.exports = function(app) {
|
|
var express = require('express');
|
|
var accountsRouter = express.Router();
|
|
|
|
accountsRouter.get('/:uid', function(req, res) {
|
|
|
|
if (/Bearer .+/.test(req.headers.authorization)) {
|
|
|
|
dbAccounts.sqlGetAccountDetails(req.params.uid)
|
|
.then(function(data) {
|
|
'use strict';
|
|
const response = {
|
|
data: {
|
|
type: 'accounts', id: data.uid, attributes: {
|
|
uid: data.uid, login: data.email, forename: data.forename,
|
|
surname: data.surname, memberof: data.member_of
|
|
}
|
|
}
|
|
};
|
|
console.log(response);
|
|
res.status(200).send(response);
|
|
})
|
|
.catch(function(err) {
|
|
console.error(err);
|
|
res.status(401).end();
|
|
});
|
|
}
|
|
});
|
|
|
|
app.use('/accounts', accountsRouter);
|
|
};
|
|
|