kellenmace / headless-wordpress-authentication-native-cookies

21 stars 8 forks source link

Set password message never runs #1

Open web-programmer-here opened 3 years ago

web-programmer-here commented 3 years ago

The password is successfully changed when setting the password but the message is never displayed:

https://github.com/kellenmace/headless-wordpress-authentication-native-cookies/blob/1f288e7ac34bfc08928b15f83fcc14c4b68f223f/components/SetPasswordForm.tsx#L71

I think the issue is here which is always false:

  const wasPasswordReset = Boolean(data?.resetUserPassword?.user?.databaseId);

it returns user as null

Object { resetUserPassword: {…} }
resetUserPassword: Object { user: null, __typename: "ResetUserPasswordPayload" }
__typename: "ResetUserPasswordPayload"
user: null
....

@kellenmace

web-programmer-here commented 3 years ago

also this issue is only for new user registration when setting a password, when a user already exist and resets the password, the message shows up

Edit: I was wrong, it also happens for existing users. It is very unreliable and some times shows the message and some times doesnt. I posted the mutation in GraphQL IDE and it always works

mutation RESET_USER_PASSWORD {
  resetUserPassword(input: {
    key: "theKeyFromTheEmail",
    login: "username",
    password: "password"
  }) {
    user {
      id
    }
  }
}

but through the frontend application it is very unreliable when testing in local

kellenmace commented 3 years ago

Hi @web-programmer-here 👋🏼

It looks to me like there's nothing wrong with the work the resetUserPassword mutation is doing, but there is an issue with the user node that we're asking for in return. For some reason, your WP backend is returning null rather than the user.

Can you please try to configure the CORS plugin on a different WordPress backend, point your decoupled frontend app to that new WP backend, then try a password reset? I'm interested to see if that results in the user's id being returned properly.

monsieurnebo commented 1 year ago

This is probably related to Apple doesn't allowing cross-domain cookies.

See the solution in this issue.