Merge pull request #13307 from strapi/fix/invite-link-not-working

Fix admin user registration
This commit is contained in:
Alexandre BODIN 2022-05-13 16:53:54 +02:00 committed by GitHub
commit b2980ab708
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -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 });
},
};

View File

@ -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 });
},

View File

@ -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));
}
});