0

I try to update user authenticate details in supabase using flask.

supabase_client.auth.update_user({"id": email,"password": new_password })

this is the am using to update the password in user authentication. First I request the password from user and then update that in Users table also in authentication.

@app.route('/reset', methods=['GET','POST'])
   def reset():
       if request.method == 'POST':
           try:
            email=request.form['email']
            new_password = request.form['new_password']
            #update new password in the supabase in table name Users
            user=supabase_client.auth.get_user()
            supabase_client.auth.update_user({"id": email,"password": new_password })
            supabase_client.from_('Users').update({'password': new_password}).eq('email', email).execute()
            flash('password is updated')
            return render_template('login.html')

This is the route I used to reset the password. But am getting API error

supabase_client.auth.update_user({"id": email,"password": new_password })

I just want to know if I'm using the correct method or not, also if someone know how to update user authentication details in supabase using flask.

2
  • You didn't post your API error. Also, what do you mean by 'this is the am using to update the password in user authentication'? Commented Mar 31, 2023 at 16:54
  • Am getting API sub claim error , this is for an website when user sets the new new password page will redirect to login page where user should log in with new password, but the problem is password isn't update in the authentication still i been able to log in using the password which I set during the signup Commented Apr 1, 2023 at 8:31

1 Answer 1

2

There are two ways to update the user data one is:

supabase_client.auth.update_user({"id": email, "password": new_password })

but for this one, the user needs to be logged in first e.g. You want to update the user email, first that user need to be logged in after that it'll update the user data otherwise it will arise the error. This method also sends you the email to the new email address. But I have face some issues in that one:

  1. It didn't send me any email to my primary email
  2. It sends me email to the new email address and it also shows in the response the updated email but didn't update it on the database.

So, I tried another method which is:

supabase_client.auth.admin.update_user_by_id({"id": email, "password": new_password })

This one updates the email in the DB, but it requires.

Continue... Still working on it will update the Answer

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.