zitadel/ts/classes.zitadeluser.ts
2024-05-02 17:43:31 +02:00

30 lines
790 B
TypeScript

import type { ZitaldelClient } from './classes.zitadelclient.js';
import type { ZitadelProjectRole } from './classes.zitadelprojectrole.js';
import * as plugins from './plugins.js';
export interface IZitadelUserData {
id: string;
lastLogin: Date;
username: string;
};
export class ZitaldelUser {
// INSTANCE
zitadelclientRef: ZitaldelClient;
data: IZitadelUserData;
constructor(zitadelclientRefArg: ZitaldelClient, dataArg: IZitadelUserData) {
this.zitadelclientRef = zitadelclientRefArg;
this.data = dataArg;
}
public async addRole(projectRole: ZitadelProjectRole) {
this.zitadelclientRef.managementClient.addUserGrant({
userId: this.data.id,
roleKeys: [projectRole.data.key],
projectId: projectRole.data.project.data.id,
});
}
}