-
Notifications
You must be signed in to change notification settings - Fork 0
/
user-update.patch.json.js
executable file
·35 lines (27 loc) · 1.12 KB
/
user-update.patch.json.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
logger.warn("SCIM: PATCH '/Users' Request with templateArgs " + url.templateArgs + " and body " + jsonUtils.toJSONString(json);
var id = url.templateArgs["id"];
var userName = json.get("userName");
var firstName = jsonUtils.toObject(json.get("name")).givenName;
var lastName = jsonUtils.toObject(json.get("name")).familyName;
var mailAddress = jsonUtils.toObject(json.get("emails"))[0].value;
var user = people.getPerson(id);
if (user) {
try {
status.code = 200;
model.user = {
"id": user.properties["cm:userName"],
"userName": user.properties["cm:userName"],
"active":people.isAccountEnabled(user.properties["cm:userName"]),
"givenName": user.properties["cm:firstName"],
"familyName": user.properties["cm:lastName"],
"email": user.properties["cm:email"]
};
} catch(error) {
status.code = 500;
status.message = "Error creating user: " + userName;
}
} else {
status.code = 404;
status.message = "User not found";
}
logger.warn("SCIM: PATCH '/Users' Request had response " + jsonUtils.toJSONString(model.user) );