mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Revert "allow null defaultRole on backend"
This reverts commit 64c995d4ccf5681bac9b10e575ce808f6e17d120.
This commit is contained in:
parent
64c995d4cc
commit
ae67e82f26
@ -103,7 +103,7 @@ describeOnCondition(edition === 'EE')('SSO Provider Options', () => {
|
||||
])('can be %s', async (name, value) => {
|
||||
const newData = {
|
||||
ssoLockedRoles: value,
|
||||
defaultRole: null,
|
||||
defaultRole: localData.restrictedRole.id, // TODO: there seems to be a bug with not setting a default role
|
||||
autoRegister: false,
|
||||
};
|
||||
const res = await requests.admin.put('/admin/providers/options', {
|
||||
@ -127,7 +127,7 @@ describeOnCondition(edition === 'EE')('SSO Provider Options', () => {
|
||||
const res = await requests.admin.put('/admin/providers/options', {
|
||||
body: {
|
||||
ssoLockedRoles: value,
|
||||
defaultRole: null,
|
||||
defaultRole: localData.restrictedRole.id, // TODO: there seems to be a bug with not setting a default role
|
||||
autoRegister: false,
|
||||
},
|
||||
});
|
||||
@ -138,49 +138,5 @@ describeOnCondition(edition === 'EE')('SSO Provider Options', () => {
|
||||
expect(Array.isArray(res.body)).toBeFalsy();
|
||||
}
|
||||
});
|
||||
|
||||
describe('autoRegister and defaultRole', () => {
|
||||
test.each([
|
||||
[null, false],
|
||||
[1, false],
|
||||
[1, true],
|
||||
])('defaultRole can be %s when autoRegister is %s', async (defaultRole, autoRegister) => {
|
||||
const newData = {
|
||||
defaultRole,
|
||||
autoRegister,
|
||||
};
|
||||
const res = await requests.admin.put('/admin/providers/options', {
|
||||
body: newData,
|
||||
});
|
||||
if (hasSSO) {
|
||||
expect(res.status).toEqual(200);
|
||||
const parsed = JSON.parse(res.text);
|
||||
expect(parsed.data).toMatchObject(newData);
|
||||
} else {
|
||||
expect(res.status).toBe(404);
|
||||
expect(Array.isArray(res.body)).toBeFalsy();
|
||||
}
|
||||
});
|
||||
|
||||
test.each([
|
||||
[null, true],
|
||||
[{}, true],
|
||||
[9999, true],
|
||||
])('defaultRole cannot be %s when autoRegister is %s', async (defaultRole, autoRegister) => {
|
||||
const newData = {
|
||||
defaultRole,
|
||||
autoRegister,
|
||||
};
|
||||
const res = await requests.admin.put('/admin/providers/options', {
|
||||
body: newData,
|
||||
});
|
||||
if (hasSSO) {
|
||||
expect(res.status).toEqual(400);
|
||||
} else {
|
||||
expect(res.status).toBe(404);
|
||||
expect(Array.isArray(res.body)).toBeFalsy();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -6,13 +6,8 @@ const providerOptionsUpdateSchema = yup.object().shape({
|
||||
autoRegister: yup.boolean().required(),
|
||||
defaultRole: yup
|
||||
.strapiID()
|
||||
.when('autoRegister', (value, initSchema) => {
|
||||
return value ? initSchema.required() : initSchema.nullable();
|
||||
})
|
||||
.required()
|
||||
.test('is-valid-role', 'You must submit a valid default role', (roleId) => {
|
||||
if (roleId === null) {
|
||||
return true;
|
||||
}
|
||||
return strapi.admin.services.role.exists({ id: roleId });
|
||||
}),
|
||||
ssoLockedRoles: yup
|
||||
|
Loading…
x
Reference in New Issue
Block a user