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);
|
||||
}
|
||||
|
||||
async get_details (context) {
|
||||
const details = {};
|
||||
async get_details (context, out) {
|
||||
out = out || {};
|
||||
|
||||
for (const provider of this.providers_) {
|
||||
const out = await provider(context);
|
||||
Object.assign(details, out);
|
||||
await provider(context, out);
|
||||
}
|
||||
|
||||
return details;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,14 @@ class GetUserService extends BaseService {
|
||||
async _init () {
|
||||
}
|
||||
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;
|
||||
|
||||
/** @type BaseDatabaseAccessService */
|
||||
|
Loading…
Reference in New Issue
Block a user