zitadel/ts/classes.zitadeluser.ts

30 lines
790 B
TypeScript
Raw Normal View History

2024-05-02 12:07:42 +00:00
import type { ZitaldelClient } from './classes.zitadelclient.js';
2024-05-02 15:43:31 +00:00
import type { ZitadelProjectRole } from './classes.zitadelprojectrole.js';
import * as plugins from './plugins.js';
2024-05-02 10:52:21 +00:00
2024-05-02 12:07:42 +00:00
export interface IZitadelUserData {
id: string;
lastLogin: Date;
username: string;
};
2024-05-02 10:52:21 +00:00
export class ZitaldelUser {
2024-05-02 15:43:31 +00:00
// INSTANCE
2024-05-02 12:07:42 +00:00
zitadelclientRef: ZitaldelClient;
2024-05-02 15:43:31 +00:00
data: IZitadelUserData;
2024-05-02 12:07:42 +00:00
constructor(zitadelclientRefArg: ZitaldelClient, dataArg: IZitadelUserData) {
this.zitadelclientRef = zitadelclientRefArg;
this.data = dataArg;
2024-05-02 10:52:21 +00:00
}
2024-05-02 15:43:31 +00:00
public async addRole(projectRole: ZitadelProjectRole) {
this.zitadelclientRef.managementClient.addUserGrant({
userId: this.data.id,
roleKeys: [projectRole.data.key],
projectId: projectRole.data.project.data.id,
});
}
2024-05-02 10:52:21 +00:00
}