• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Hello, i am making tasks correctly but it still gives me sign up fail, whats wrong

shakoc

Lurker
Code:
package com.trashysofts.auct


import android.content.Intent
import android.os.Bundle
import android.util.Patterns
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.auth.FirebaseAuth
import kotlinx.android.synthetic.main.register_layout.*

class RegisterActivity : AppCompatActivity() {

    private lateinit var auth: FirebaseAuth

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.register_layout)
        auth = FirebaseAuth.getInstance()
        buttonJoin.setOnClickListener {
            signUpUser()
        }

    }

    private fun signUpUser() {
        if (emailTextSignUp.text.toString().isEmpty()) {
            emailTextSignUp.error = "Please enter email"
            emailTextSignUp.requestFocus()
            return
        }
        if (!Patterns.EMAIL_ADDRESS.matcher(emailTextSignUp.text.toString()).matches()) {
            emailTextSignUp.error = "Please enter valid email"
            emailTextSignUp.requestFocus()
            return
        }
        if (passwordTextSignUp.text.toString().isEmpty()) {
            passwordTextSignUp.error = "Please enter password"
            passwordTextSignUp.requestFocus()
            return
        }
        auth.createUserWithEmailAndPassword(emailTextSignUp.text.toString(), passwordTextSignUp.text.toString())
            .addOnCompleteListener(this) { task ->
                if (task.isSuccessful) {
                    startActivity(Intent(this,LoginActivity::class.java))
                    finish()
                } else {
                    Toast.makeText(baseContext, "Sign Up failed",
                        Toast.LENGTH_SHORT).show()
                }
            }
    }
}
 
Back
Top Bottom