fix some issues
This commit is contained in:
parent
3470a4ce60
commit
2ea4cd21a0
6 changed files with 12 additions and 11 deletions
|
@ -35,6 +35,7 @@ export class GroupEndpoint extends ScimEndpoint implements IScimEndpoint {
|
|||
const targetIds = new Set<string>(
|
||||
SCIMGroup.fromPlain(ctx.content()).members.map((x) => x.value),
|
||||
);
|
||||
targetIds.add(await ctx.rc.getUserId());
|
||||
const currentIds = new Set<string>(
|
||||
membersRaw.members.map((x) => x.user._id),
|
||||
);
|
||||
|
|
|
@ -24,7 +24,7 @@ export class UserEndpoint extends ScimEndpoint implements IScimEndpoint {
|
|||
userId: ctx.id(),
|
||||
data: {
|
||||
email: u.getEmail(),
|
||||
name: u.displayName,
|
||||
name: u.displayName || undefined,
|
||||
username: u.userName,
|
||||
active: u.active,
|
||||
verified: true,
|
||||
|
|
|
@ -30,10 +30,7 @@ export class UsersEndpoint extends ScimEndpoint implements IScimEndpoint {
|
|||
const u = SCIMUser.fromPlain(ctx.content());
|
||||
const o = await ctx.rc.user.create({
|
||||
email: u.getEmail(),
|
||||
name:
|
||||
u.displayName ||
|
||||
`${u.name.givenName} ${u.name.familyName}` ||
|
||||
u.userName,
|
||||
name: u.displayName || u.userName,
|
||||
username: u.userName,
|
||||
password: crypto.randomBytes(64).toString("base64").slice(0, 64),
|
||||
verified: true,
|
||||
|
|
|
@ -70,6 +70,14 @@ export class RcSdk {
|
|||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
public async getUserId(): Promise<string> {
|
||||
return await this.read
|
||||
.getEnvironmentReader()
|
||||
.getSettings()
|
||||
.getValueById("rc-user-id");
|
||||
}
|
||||
|
||||
private buildUrl(url: string): string {
|
||||
return `${this.baseUrl}/${url}`;
|
||||
}
|
||||
|
@ -77,10 +85,7 @@ export class RcSdk {
|
|||
private async buildOptions(content?: any): Promise<IHttpRequest> {
|
||||
const options: IHttpRequest = {
|
||||
headers: {
|
||||
"X-User-Id": await this.read
|
||||
.getEnvironmentReader()
|
||||
.getSettings()
|
||||
.getValueById("rc-user-id"),
|
||||
"X-User-Id": await this.getUserId(),
|
||||
"X-Auth-Token": await this.read
|
||||
.getEnvironmentReader()
|
||||
.getSettings()
|
||||
|
|
|
@ -23,7 +23,6 @@ export class SCIMGroup implements ISCIMResource {
|
|||
value: member.user._id,
|
||||
$ref: `/Users/${member.user._id}`,
|
||||
display: member.user.name,
|
||||
type: "User",
|
||||
}));
|
||||
return group;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ export class SCIMUser implements ISCIMResource {
|
|||
public static fromRC(rc: IUser): SCIMUser {
|
||||
const user = new SCIMUser();
|
||||
user.id = rc._id;
|
||||
user.externalId = rc._id;
|
||||
user.setEmail(rc.emails[0].address);
|
||||
user.displayName = rc.name;
|
||||
user.userName = rc.username;
|
||||
|
|
Reference in a new issue