0
votes

I am working on password reset and I have used django rest-auth, I have successfully got the token and uid from email link by hitting rest-auth/password/reset/,

but for to confirm I want the token and uid in react form so I can change it how can I get the uid and token which the rest auth return in email link in react js form

           axios.post('http://127.0.0.1:8000/rest-auth/password/reset/',payload)
        .then(res=>{
            console.log(res)
        })
        .catch(err=>{
            console.log(err)
        })

its working perfect and it returns me:

    http://127.0.0.1:8000/rest-auth/password/reset/confirm/MQ/594-5faaa46be4277e6a1879/

how can I get the uid and token from url in react form?

1
using regex could be one way, for extracting the uid & tokenPrabhat Mishra

1 Answers

0
votes

You should configure your react router to get the params from url.

  e.preventDefault();
        fetch("http://127.0.0.1:8000/rest-auth/password/reset/confirm/", {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            }, body: JSON.stringify({
                "new_password1": this.state.new_password1,
                "new_password2": this.state.new_password2,
                "uid": this.props.match.params.uid,
                "token": this.props.match.params.token,
            })
        })
            // .then(response => response.json())
            .then(response => {
                console.log(response)
            })
            .catch(error => {
                console.log(error)
            })