0

I followed the steps from the documentation on setting up the email password authentication and it worked fine for a while now. I don't know why but yesterday it just stopped working and keeps giving me the error : W/System: Ignoring header X-Firebase-Locale because its value was null.

The app won't allow me to log in or sign-up anymore.

But the problem only occurs when I test my app while connected via WiFi and it works as expected when I am connected to mobile data (LTE).

I tried connecting to a VPN, in hopes that the problem is with my service provider, but the problem remained.

I've also tried testing the app on a different device, the error is still there.


I've tried following the steps provided by these answers:

https://stackoverflow.com/a/65106158/16296874

https://stackoverflow.com/a/66993601/16296874

https://stackoverflow.com/a/64657110

but nothing seems to be working.

I've seen lots of people encountered this problem and being solved in different ways. And trying those did not seem to have an effect. So I'm not sure anymore.

package com.sunnyside.kookoo.verification.ui.fragments

import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.navigation.fragment.findNavController
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase
import com.sunnyside.kookoo.R
import com.sunnyside.kookoo.databinding.FragmentLoginBinding
import com.sunnyside.kookoo.databinding.FragmentProfileBinding
import com.sunnyside.kookoo.student.ui.StudentActivity
import com.sunnyside.kookoo.testKolanglods.ui.PangTestingLangLodsActivity


class LoginFragment : Fragment() {

    private lateinit var auth: FirebaseAuth

    private var _binding: FragmentLoginBinding? = null
    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        _binding = FragmentLoginBinding.inflate(inflater, container, false)
        val view = binding.root

        auth = Firebase.auth


        binding.textLoginRegister.setOnClickListener {
            findNavController().navigate(R.id.action_loginFragment_to_signupFragment)
        }

        binding.loginbtnBack.setOnClickListener {
            findNavController().navigate(R.id.action_loginFragment_to_welcomeFragment)
        }

        binding.resetPasswordTxt.setOnClickListener {
            findNavController().navigate(R.id.action_loginFragment_to_resetFragment)
        }

        binding.loginBtn.setOnClickListener {
            login()
        }


        return view
    }

    private fun login() {
        val email = binding.loginEmail.text.toString()
        val password = binding.loginPassword.text.toString()
        binding.llProgressBar.root.visibility = View.VISIBLE
        auth.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener { task ->
                if (task.isSuccessful) {
                    // Sign in success, update UI with the signed-in user's information
                    Log.d("AUTH", "signInWithEmail:success")
                    val intent = Intent(activity, StudentActivity::class.java)
                    activity?.startActivity(intent)

                } else {
                    // If sign in fails, display a message to the user.
                    Log.w("AUTH",  "signInWithEmail:failure", task.exception)
                    Toast.makeText(
                        context, "Authentication failed.",
                        Toast.LENGTH_SHORT
                    ).show()
                }
            }

    }
    

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }

}

1 Answers1

0

Check date(rules) in Firebase .

Code Scan
  • 42
  • 8
  • I've already updated the security rules and got it working last time. But I will double-check to see if there are rules that are being the source of the issue. Thank you!!! – studentmorrisjohn Jun 24 '21 at 01:35