Skip to content

Commit

Permalink
Send confirmation token if user password is missing on create
Browse files Browse the repository at this point in the history
  • Loading branch information
cipick committed Jul 13, 2023
1 parent 65d5247 commit 210db3f
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ const sendMailToUserWhenUserIsInvited = (to, data) =>
);

module.exports = {
async beforeCreate(event) {
event.params.data.provider = "local";
event.params.data.username = event.params.data.email;
event.params.data.role = 1;
event.params.data.confirmed = true;
},
async afterCreate(event) {
const { result, params } = event;

if (!params.data.createdBy) {
if (!params.data.password) {
const registrationToken = strapi.service("admin::token").createToken();

await strapi.plugin("users-permissions").service("user").edit(result.id, {
username: result.email,
registrationToken,
provider: "local",
role: 1,
confirmed: true,
});

try {
Expand Down

1 comment on commit 210db3f

@vercel
Copy link

@vercel vercel bot commented on 210db3f Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.