Hi,
I have a question about the “username” attribute in the Users collection from the Users & Permissions plugin. By default, it is set as a “required” and “unique” attribute. We can, of course, change this in users-permissions/content-types/user/schema.json
. In my case, I set the “required” and “unique” keys to true
for the “email” field. However, yesterday I spent some time trying to leave only the email and password fields during registration, instead of requiring a username, email, and password (I understand we can bypass this by assigning the email to the username in the mutation).
Now, my question is: can this be achieved by modifying the relevant parts of plugin.controllers.auth.register
as follows?
const { email, *remove username*, provider } = params;
const identifierFilter = email.toLowerCase();
* leaving only the email
$or: [
{ },
{ username: email.toLowerCase() },
{ username },
{ email: username },
],
};
*
etc. I’m still getting familiar with Strapi. I’ve looked through the documentation but I’m not sure how to modify the UsersPermissionsRegisterInput
type in graphql/types/register-input.js
:
module.exports = ({ nexus }) => {
return nexus.inputObjectType({
name: 'UsersPermissionsRegisterInput',
definition(t) {
*remove t.nonNull.string('username');*
t.nonNull.string('email');
t.nonNull.string('password');
},
});
};
I’m not sure whether it’s worth the effort to override this in the extensions
folder or if it’s better to leave it as is. I assume that the username
might be required in other functions, mutations, or types, and this could lead to more complications.
Any advice or guidance would be appreciated.
Thanks!