@opengis/admin
Version:
This project Softpro Admin
18 lines (13 loc) • 648 B
JavaScript
export default async function userInfo({
pg, session = {},
}) {
const { uid } = session.passport?.user || {};
if (!uid) {
return { message: 'access restricted', status: 403 };
}
const data = await pg.query(`select user_name, sur_name, father_name, user_rnokpp, user_type, email, login from admin.users
where uid=$1`, [uid]).then((res) => res.rows?.[0] || {});
const { notifications = 0 } = await pg.query(`select count(*)::int as notifications from crm.notifications
where addressee_id=$1 and read is not true`, [uid]).then((res) => res.rows?.[0] || {});
return { uid, ...data, notifications };
}