@@ -66,48 +66,12 @@ export class DBHelper {
6666 Logger . otel . endSpan ( span ) ;
6767 }
6868 }
69- // public static async GetRoles(_id: string, ident: number, parent: Span): Promise<Role[]> {
70- // const span: Span = Logger.otel.startSubSpan("dbhelper.GetRoles", parent);
71- // span.setAttribute("_id", _id);
72- // span.setAttribute("ident", ident);
73- // try {
74- // if (ident > Config.max_recursive_group_depth) return [];
75- // const result: Role[] = [];
76- // const query: any = { "members": { "$elemMatch": { _id: _id } } };
77- // const ids: string[] = [];
78- // const _roles: Role[] = await Config.db.query<Role>(query, null, Config.expected_max_roles, 0, null, "users", Crypt.rootToken(), undefined, undefined, span);
79- // for (let role of _roles) {
80- // if (ids.indexOf(role._id) == -1) {
81- // ids.push(role._id);
82- // result.push(role);
83- // const _subroles: Role[] = await this.GetRoles(role._id, ident + 1, span);
84- // for (let subrole of _subroles) {
85- // if (ids.indexOf(subrole._id) == -1) {
86- // ids.push(subrole._id);
87- // result.push(subrole);
88- // }
89- // }
90- // }
91- // }
92- // return result;
93- // } catch (error) {
94- // span.recordException(error);
95- // throw error;
96- // } finally {
97- // Logger.otel.endSpan(span);
98- // }
99- // }
10069 public static cached_roles : Role [ ] = [ ] ;
10170 public static cached_at : Date = new Date ( ) ;
10271 public static async DecorateWithRoles ( user : User , parent : Span ) : Promise < User > {
10372 const span : Span = Logger . otel . startSubSpan ( "dbhelper.DecorateWithRoles" , parent ) ;
10473 try {
10574 if ( ! Config . decorate_roles_fetching_all_roles ) {
106- // const roles: Role[] = await this.GetRoles(user._id, 0, span);
107- // user.roles = [];
108- // roles.forEach(role => {
109- // user.roles.push(new Rolemember(role.name, role._id));
110- // });
11175 const pipe : any = [ { "$match" : { "_id" : user . _id } } ,
11276 {
11377 "$graphLookup" : {
0 commit comments