eager-peach
eager-peach6mo ago

How do I pass query params from UpdatePasswordPage to updatePassword function in authProvider

How do I pass query params from UpdatePasswordPage to updatePassword function in authProvider?




3 Replies
kapa.ai
kapa.ai6mo ago
Hi @chachi. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In Refine, the updatePassword method in the authProvider can take query parameters as arguments from the URL. If we assume that the URL is <http://localhost:3000/reset-password?token=123,> the updatePassword method will get the mutation's parameters as arguments and the token query parameter as well. Here is an example of how you can define the updatePassword method in your authProvider:
const authProvider: AuthProvider = {
// ---
updatePassword: async ({ password, confirmPassword, token }) => {
console.log(token); // 123

// if request is successful
return {
success: true,
redirectTo: "/login",
};
},
};
const authProvider: AuthProvider = {
// ---
updatePassword: async ({ password, confirmPassword, token }) => {
console.log(token); // 123

// if request is successful
return {
success: true,
redirectTo: "/login",
};
},
};
In this example, the updatePassword method is an async function that takes an object as its argument. This object contains the password, confirmPassword, and token properties. The token property is the query parameter from the URL. For more information, you can refer to the Refine documentation (https://refine.dev/docs/authentication/auth-provider#updatepassword). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@95552725294518272> kapa.ai is still learning and improving, please let us know how it did by reacting below
like-gold
like-gold6mo ago
Hello @chachi, all mutation parameters will be sent to updatePasswords
const { mutate: updatePassword } = useUpdatePassword<any>();
updatePassword({
redirectPath: "/custom-url",
query: "?foo=bar",
});
const { mutate: updatePassword } = useUpdatePassword<any>();
updatePassword({
redirectPath: "/custom-url",
query: "?foo=bar",
});
`
updatePassword: async (params) => {
console.log(params); // { redirectPath: "/custom-url", query: "?foo=bar" }
return {
success: true,
};
},
updatePassword: async (params) => {
console.log(params); // { redirectPath: "/custom-url", query: "?foo=bar" }
return {
success: true,
};
},