invertase / dart_firebase_admin

🔥 A Firebase Admin SDK for Dart.
Apache License 2.0
118 stars 32 forks source link

Updating user data based on UID fails #21

Closed jusuf-el closed 2 months ago

jusuf-el commented 7 months ago

I have issue updating the user data based on user's bid. First, I retrieve the user's data by email, and I get what I expect. Then, I used the uid from the response for updating the user's data, but I keep getting the following error:

E/flutter (13587): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FirebaseAuthAdminException: auth/missinguid: A uid identifier is required for the current operation.
E/flutter (13587): #0      validateResponse (package:_discoveryapis_commons/src/api_requester.dart:306:9)
E/flutter (13587): <asynchronous suspension>
E/flutter (13587): #1      ApiRequester.request (package:_discoveryapis_commons/src/api_requester.dart:72:16)
E/flutter (13587): <asynchronous suspension>
E/flutter (13587): #2      AccountsResource.update (package:firebaseapis/identitytoolkit/v1.dart:714:23)
E/flutter (13587): <asynchronous suspension>
E/flutter (13587): #3      _AuthHttpClient.setAccountInfo.<anonymous closure> (package:dart_firebase_admin/src/auth/auth_api_request.dart:966:24)
E/flutter (13587): <asynchronous suspension>
E/flutter (13587): #4      _AbstractAuthRequestHandler.updateExistingAccount (package:dart_firebase_admin/src/auth/auth_api_request.dart:733:22)
E/flutter (13587): <asynchronous suspension>
E/flutter (13587): #5      _BaseAuth.updateUser (package:dart_firebase_admin/src/auth/base_auth.dart:772:9)
E/flutter (13587): <asynchronous suspension>
E/flutter (13587): #6      LoginController.login.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:stock_log/app/modules/login/controllers/login_controller.dart:162:23)
E/flutter (13587): <asynchronous suspension>
E/flutter (13587): #7      LoginController.login.<anonymous closure>.<anonymous closure> (package:stock_log/app/modules/login/controllers/login_controller.dart:149:13)
E/flutter (13587): <asynchronous suspension>
E/flutter (13587): #8      LoginController.login.<anonymous closure> (package:stock_log/app/modules/login/controllers/login_controller.dart:144:11)
E/flutter (13587): <asynchronous suspension>
E/flutter (13587): #9      LoginController.login (package:stock_log/app/modules/login/controllers/login_controller.dart:87:28)
E/flutter (13587): <asynchronous suspension>
E/flutter (13587): 

Here is my code:

await auth.getUserByEmail(email.value).then((user) async {
            String uid = user.uid;
            await auth
                .updateUser(uid, ath.UpdateRequest(password: code.toString()))
                .then((value) async {
              print('USER UPDATED');
              print(value.toJson());
            });
          });
HeySreelal commented 7 months ago

The exception occurred because the UID was missing in the update request (possibly missed implementation in the package). Added a PR to fix!

jusuf-el commented 7 months ago

@HeySreelal when we can expect the fix to be merged, so we can continue with our work that is dependent to this issue.

Thank you once again!

HeySreelal commented 7 months ago

I'm actually unsure about the timelines. May be an admin can help you with that. Fix is actually a one liner, you can check this commit: 8315f5373ed7e72d93cba02fffa67e3cb69e3ea7. In addition to that, you could add it locally on your machine/server and continue your work while waiting for the PR to be merged. Best :)

AbuBakar044 commented 1 week ago

Still facing the issue (currently using the 0.3.1 version FirebaseAuthAdminException: auth/missinguid: A uid identifier is required for the current operation.

This is the function

await auth.updateUser( uid, UpdateRequest( email: emailCtrl.text, password: passCtrl.text, ));

HeySreelal commented 1 week ago

Hi @AbuBakar044, I can see that this fix hasn't been released to pub.dev yet. I'm not sure why though :) Probably there'll be an update soon.