mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 19:04:38 +00:00
Merge pull request #13307 from strapi/fix/invite-link-not-working
Fix admin user registration
This commit is contained in:
commit
b2980ab708
@ -29,6 +29,10 @@ module.exports = {
|
||||
const createdUser = await getService('user').create(attributes);
|
||||
const userInfo = getService('user').sanitizeUser(createdUser);
|
||||
|
||||
// Note: We need to assign manually the registrationToken to the
|
||||
// final user payload so that it's not removed in the sanitation process.
|
||||
Object.assign(userInfo, { registrationToken: createdUser.registrationToken });
|
||||
|
||||
ctx.created({ data: userInfo });
|
||||
},
|
||||
};
|
||||
|
||||
@ -36,6 +36,10 @@ module.exports = {
|
||||
|
||||
const userInfo = getService('user').sanitizeUser(createdUser);
|
||||
|
||||
// Note: We need to assign manually the registrationToken to the
|
||||
// final user payload so that it's not removed in the sanitation process.
|
||||
Object.assign(userInfo, { registrationToken: createdUser.registrationToken });
|
||||
|
||||
// Send 201 created
|
||||
ctx.created({ data: userInfo });
|
||||
},
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const _ = require('lodash');
|
||||
const { omit } = require('lodash/fp');
|
||||
const { createStrapiInstance } = require('../../../../../test/helpers/strapi');
|
||||
const { createAuthRequest } = require('../../../../../test/helpers/request');
|
||||
const { createUtils } = require('../../../../../test/helpers/utils');
|
||||
|
||||
const edition = process.env.STRAPI_DISABLE_EE === 'true' ? 'CE' : 'EE';
|
||||
|
||||
const omitTimestamps = obj => _.omit(obj, ['updatedAt', 'createdAt']);
|
||||
const omitTimestamps = omit(['updatedAt', 'createdAt']);
|
||||
const omitRegistrationToken = omit(['registrationToken']);
|
||||
|
||||
/**
|
||||
* == Test Suite Overview ==
|
||||
@ -128,9 +129,10 @@ describe('Admin User CRUD (e2e)', () => {
|
||||
|
||||
expect(res.statusCode).toBe(201);
|
||||
expect(res.body.data).not.toBeNull();
|
||||
expect(res.body.data).toHaveProperty('registrationToken');
|
||||
|
||||
// Using the created user as an example for the rest of the tests
|
||||
testData.user = res.body.data;
|
||||
testData.user = omitRegistrationToken(res.body.data);
|
||||
});
|
||||
|
||||
test('3. Creates users with superAdmin role (success)', async () => {
|
||||
@ -153,7 +155,7 @@ describe('Admin User CRUD (e2e)', () => {
|
||||
expect(res.statusCode).toBe(201);
|
||||
expect(res.body.data).not.toBeNull();
|
||||
|
||||
testData.otherSuperAdminUsers.push(res.body.data);
|
||||
testData.otherSuperAdminUsers.push(omitRegistrationToken(res.body.data));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user