mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
Use default role on register action
This commit is contained in:
parent
9b7a216411
commit
88afad1502
@ -209,12 +209,14 @@ module.exports = {
|
||||
},
|
||||
|
||||
register: async (ctx) => {
|
||||
if (!(await strapi.store({
|
||||
const settings = await strapi.store({
|
||||
environment: '',
|
||||
type: 'plugin',
|
||||
name: 'users-permissions',
|
||||
key: 'advanced'
|
||||
}).get()).allow_register) {
|
||||
}).get();
|
||||
|
||||
if (!settings.allow_register) {
|
||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.advanced.allow_register' }] }] : 'Register action is currently disabled.');
|
||||
}
|
||||
|
||||
@ -241,7 +243,7 @@ module.exports = {
|
||||
const hasAdmin = users.length > 0;
|
||||
|
||||
// Check if the user is the first to register
|
||||
const role = hasAdmin === false ? root : await strapi.query('role', 'users-permissions').findOne({ type: 'guest' }, []);
|
||||
const role = hasAdmin === false ? root : await strapi.query('role', 'users-permissions').findOne({ type: settings.default_role }, []);
|
||||
|
||||
if (!role) {
|
||||
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Auth.form.error.role.notFound' }] }] : 'Impossible to find the root role.');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user