https://www.ory.sh/ logo
#talk-kratos
Title
# talk-kratos
b

boundless-hydrogen-45841

11/10/2021, 9:05 AM
what must be the request body for update password flow in kratos. When I am making the request it is redirecting me to the same settings page where I am updating password. I think there is some validation erorr which I am not able to findout.
p

proud-plumber-24205

11/10/2021, 10:11 AM
Hi @boundless-hydrogen-45841 Please check out this section of the docs https://www.ory.sh/kratos/docs/self-service/flows/user-settings/#update-password
b

boundless-hydrogen-45841

11/10/2021, 10:29 AM
hey @proud-plumber-24205 I went through that portion, I am trying to make a form request for updating the password
Copy code
const changePassword = (values) => {
    // values is the content i.e. password
    // ui is the response for settings flow
    var updatePasswordForm = document.createElement('form');
    updatePasswordForm.action = ui.action;
    updatePasswordForm.method = ui.method;
    updatePasswordForm.style.display = 'none';

    var passwordInput = document.createElement('input');
    passwordInput.name = 'password';
    passwordInput.value = values.password;

    var csrfInput = document.createElement('input');
    csrfInput.name = 'csrf_token';
    csrfInput.value = ui.nodes.find((value) => {
      if (value.attributes.name === 'csrf_token') {
        return value;
      }
    }).attributes.value;

    var methodInput = document.createElement('input');
    methodInput.name = 'method';
    methodInput.value = 'password'; 

    updatePasswordForm.appendChild(passwordInput);
    updatePasswordForm.appendChild(methodInput);
    updatePasswordForm.appendChild(csrfInput);
    document.body.appendChild(updatePasswordForm);
    updatePasswordForm.submit();
  };
hey @proud-plumber-24205 that problem is solved. While updating password one has to also pass the email i.e ''password_identifier"
p

proud-plumber-24205

11/10/2021, 10:56 AM
@boundless-hydrogen-45841 that's good to hear 🙂 A good tip is to always look at what the error message is when it redirects you back
b

boundless-hydrogen-45841

11/10/2021, 10:57 AM
thank you @proud-plumber-24205
7 Views