mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
feat(backend): allow services to provide user properties
This commit is contained in:
parent
71e2310fa4
commit
522664d415
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user