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