E
E
Evgeny Bykov2019-08-27 17:31:17
Android
Evgeny Bykov, 2019-08-27 17:31:17

How to fix error with adding information in Firebase Database?

There is the following function:

if (fullname.isNotEmpty() && password.isNotEmpty()) {
            val email = mEmail
            if (email != null) {
                mAuth.createUserWithEmailAndPassword(email, password)
                    .addOnCompleteListener {
                        if (it.isSuccessful) {
                            val user = makeUser(fullname, email)
                            val reference = mDatabase.child("users").child(it.result!!.user!!.uid)

                            reference.setValue(user).addOnCompleteListener {
                                    if (it.isSuccessful) {
                                        startHomeActivity()
                                    } else {
                                        Log.e(TAG, "Failed to create user profile", it.exception)
                                        showToast("Something wrong happened. Please try again later")
                                    }
                                }
                        } else {
                            Log.e(TAG, "Failed to create user", it.exception)
                            showToast("Something wrong happened. Please try again later")
                        }
                    }
            } else {
                Log.e(TAG, "onRegister: email is null")
                showToast("Please enter email")
                supportFragmentManager.popBackStack()
            }
        } else {
            showToast("Please enter full name and password")
        }

Authentication is successful, but the data in the database cannot be created. Outputs the following: "om.google.firebase.database.DatabaseException: Firebase Database error: Permission denied"
Although, if you go to the firebase console --> Database --> Rules, you will see the following: "You have security rules set that assume open access All users can copy, modify, and delete data in your database."
So what's the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question