Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I approve user to register (change the custom claim) in the firebase console?

class RegisterAPIView(APIView):
    def post(self, request, format=None):
        email = request.data.get('email')
        password = request.data.get('password')
        
        # Create user with Firebase
        try:
            user = auth.create_user(email=email, password=password)
        except auth.EmailAlreadyExistsError:
            return JsonResponse({'error': 'Unable to create account'})

        # Set custom user claims for the new user
        auth.set_custom_user_claims(user.uid, {'is_approved': False})
        
        return JsonResponse({'success': 'Account created successfully'})

This is a Django REST Framework API, which is creating a new user in fireabase and setting custom claim is_approved False. After registration the user appears in the firebase console. How can I approve user to register (change the custom claim) in the firebase console?
I can do it with code but can’t manage in the console.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

There is no way to change a user’s custom claims in the Firebase console. To change a user’s custom claim, you’ll have to call the API as you already do.

The only alternative I know off is the Set Auth claims with Firestore experimental extension, which synchronizes claims for a user between their auth profile and a companion document in Firestore.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading