Imported users can't login,

System Information
  • Strapi Version: 3.5.3
  • Operating System: Mac OSX
  • Database: MongoDB
  • Node Version: v12.14.0
  • NPM Version: 6.13.4
  • Yarn Version: -

Hi, i have imported my users from another CMS, and created the users by extending the users-permssions extension and add the users with this code;

const userData = {
            username: name,
            email,
            confirmed: 1,
            role: ["5eae92b243f9162da3292e90"],
            firstname,
            lastname,
            prev_user_id: id,
          };

          const createdUser = await strapi.plugins[
            "users-permissions"
          ].services.user.add(userData);

This worked well and my users accounts are now available in my backend.
However, since they don’t have a password (yet), i am sending them to ‘forgot password’ page, and letting them reset there password for the first time, with this code;

axios
  .post("http://localhost:1337/auth/reset-password", {
    code: code, // code contained in the reset link of step 3.
    password: data.password,
    passwordConfirmation: data.passwordConfirmation,
  })
  .then((response) => {
    console.log(response);
    console.log("Your user's password has been reset.");
    auth.setToken(response.data.jwt);
    setSuccess(true);
  })
  .catch((error) => {
    console.log("An error occurred:", error.response);
    // error message
    console.log("ERROR!");
  });

This is also working well, i get a 200 repsonse saying the users password has changed, and getting a jwt code so i can login the user.

However, when i log out the user, and login with the password created with the ‘forgot password’ steps, i always get a 400 response, with “id”:“Auth.form.error.invalid”,“message”:“Identifier or password invalid.”.

How can i solve this problem? I’m 100% sure the credentials where right…

1 Like

Have you solved this? I’m running into the same issue.

1 Like