Add function to get user information
parent
173c075aa3
commit
4d3b6989e4
|
@ -75,6 +75,16 @@ async function retrieveAll() {
|
|||
return accountsList;
|
||||
}
|
||||
|
||||
async function getFromID(id) {
|
||||
const query = `SELECT user_id, email, admin
|
||||
FROM accounts.users
|
||||
WHERE user_id = $1;`;
|
||||
const row = (await database.executeQuery(query, [id]))[0];
|
||||
|
||||
return new User(id, row[1], row[2]);
|
||||
}
|
||||
|
||||
exports.createUser = createUser;
|
||||
exports.retrieveAll = retrieveAll;
|
||||
exports.getFromID = getFromID;
|
||||
exports.passport = passport;
|
|
@ -75,4 +75,10 @@ export async function getAccounts() {
|
|||
const response = await fetch(`/data/accounts`);
|
||||
const accounts = await response.json();
|
||||
return accounts;
|
||||
}
|
||||
|
||||
export async function getAccount(accountID) {
|
||||
const response = await fetch(`/data/account?account=${accountID}`);
|
||||
const account = await response.json();
|
||||
return account;
|
||||
}
|
|
@ -76,4 +76,9 @@ router.get('/accounts', adminLoggedIn, function(req, res, next) {
|
|||
.then(data => res.json(data));
|
||||
})
|
||||
|
||||
router.get('/account', adminLoggedIn, function(req, res, next) {
|
||||
accounts.getFromID(req.query.account)
|
||||
.then(data => res.json(data));
|
||||
})
|
||||
|
||||
module.exports = router;
|
Reference in New Issue