Trim names of client, realm role, user and group before saving (#1639)

This commit is contained in:
Jon Koops 2021-12-06 17:32:52 +01:00 committed by GitHub
parent e53c7744a1
commit 7cef4ae2d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 1 deletions

View file

@ -274,6 +274,9 @@ export default function ClientDetails() {
webOrigins,
attributes,
};
newClient.clientId = newClient.clientId?.trim();
await adminClient.clients.update({ id: clientId }, newClient);
setupForm(newClient);
setClient(newClient);

View file

@ -51,6 +51,7 @@ export default function NewClientForm() {
try {
const newClient = await adminClient.clients.create({
...client,
clientId: client.clientId?.trim(),
attributes,
});
addAlert(t("createSuccess"), AlertVariant.success);

View file

@ -38,6 +38,8 @@ export const GroupsModal = ({
});
const submitForm = async (group: GroupRepresentation) => {
group.name = group.name?.trim();
try {
if (!id) {
await adminClient.groups.create(group);

View file

@ -120,6 +120,9 @@ export default function RealmRoleTabs() {
}
const { attributes, ...rest } = values;
let roleRepresentation: RoleRepresentation = rest;
roleRepresentation.name = roleRepresentation.name?.trim();
if (id) {
if (attributes) {
roleRepresentation.attributes = arrayToAttributes(attributes);

View file

@ -81,6 +81,8 @@ const UsersTabs = () => {
};
const save = async (user: UserRepresentation) => {
user.username = user.username?.trim();
try {
if (id) {
await adminClient.users.update({ id }, user);
@ -99,7 +101,7 @@ const UsersTabs = () => {
history.push(toUser({ id: createdUser.id, realm, tab: "settings" }));
}
} catch (error) {
addError("userCreateError", error);
addError("users:userCreateError", error);
}
};