feat(backend): allow services to provide user properties

This commit is contained in:
KernelDeimos 2024-05-31 18:10:11 -04:00
parent 71e2310fa4
commit 522664d415
2 changed files with 12 additions and 5 deletions

View File

@ -14,15 +14,14 @@ class DetailProviderService extends BaseService {
this.providers_.push(fn); this.providers_.push(fn);
} }
async get_details (context) { async get_details (context, out) {
const details = {}; out = out || {};
for (const provider of this.providers_) { for (const provider of this.providers_) {
const out = await provider(context); await provider(context, out);
Object.assign(details, out);
} }
return details; return out;
} }
} }

View File

@ -26,6 +26,14 @@ class GetUserService extends BaseService {
async _init () { async _init () {
} }
async get_user (options) { async get_user (options) {
const user = await this.get_user_(options);
if ( ! user ) return null;
const svc_whoami = this.services.get('whoami');
await svc_whoami.get_details({ user }, user);
return user;
}
async get_user_ (options) {
const services = this.services; const services = this.services;
/** @type BaseDatabaseAccessService */ /** @type BaseDatabaseAccessService */