• 13
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I'm using firebase and android studio. and I have a problem that is occured while I trying delete user. What is only one way to access My Application is phonenumber authentication.

I already know about that when I delete user, must have to reauthentication. So I refered to firebase docs and tried them. AuthCredential.getCredential() method requires several values although I have only PhoneNumber and UID. that is all I know

This is the code

AuthCredential credential = PhoneAuthProvider
                        .getCredential(user.getUid(), null);

                user.reauthenticate(credential)
                .addOnCompleteListener(new OnCompleteListener<Void>() {

                    //??? ???
                    @Override
                    public void onComplete(@NonNull Task<Void> task) {

                        //??
                        user.delete()
                        .addOnCompleteListener(new OnCompleteListener<Void>() {
                            @Override
                            public void onComplete(@NonNull Task<Void> task) {
                                if (task.isSuccessful()) {
                                    Log.d("result", "User account deleted.");
                                }else{
                                    Log.d("", task.getException().getStackTrace().toString());
                                }
                            }
                        });
                    }
                });

And This is the Exceptions :

java.lang.IllegalArgumentException: Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof.
        at com.google.android.gms.common.internal.Preconditions.checkArgument(Unknown Source)
        at com.google.firebase.auth.PhoneAuthCredential.<init>(Unknown Source)
        at com.google.firebase.auth.PhoneAuthProvider.getCredential(Unknown Source)
        at com.dataflow.deliverytalk.Activities.popup.LogoutPopupActivity$1$override.onClick(LogoutPopupActivity.java:58)
        at com.dataflow.deliverytalk.Activities.popup.LogoutPopupActivity$1$override.access$dispatch(LogoutPopupActivity.java)
        at com.dataflow.deliverytalk.Activities.popup.LogoutPopupActivity$1.onClick(LogoutPopupActivity.java)
        at android.view.View.performClick(View.java:5637)
        at android.view.View$PerformClick.run(View.java:22429)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Apparently you can also delete user using cloud function without having to re-authenticate user and by just providing the uid. Here's how

exports.deleteUser = functions.https.onRequest((req, res) => {
  if (req.body.uid === undefined) {
    res.status(400).send('No user id defined');
  } else {
    var userId = req.body.uid;

    admin.auth().deleteUser(userId)
        .then(function() {
            console.log("Successfully deleted user");    
        })
        .catch(function(error) {
            console.log("Error deleting user: ", error);
        });

    res.status(200).end();
}
});

More info

  • 1
Reply Report