class MainActivity : AppCompatActivity() { private var mauth = FirebaseAuth.getInstance() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) setSupportActionBar(toolbar) requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT val email = findViewById<View>(R.id.editT1) as EditText val password = findViewById<View>(R.id.editText4) as EditText val btn = findViewById<View>(R.id.button2) as Button val button = findViewById<View>(R.id.button4) as Button email.setOnFocusChangeListener { view, b -> if (email.text.toString().contains("@") &&
email.text.toString().contains(".com")) { toast("Valid Email Address") btn.isEnabled = true button.isEnabled=true } else { toast("Invalid Email Address") btn.isEnabled = false button.isEnabled=false } } btn.setOnClickListener { toast("Logging In") mauth!!.signInWithEmailAndPassword(email.text.toString().trim(),
password.text.toString().trim()) .addOnCompleteListener(this){ task-> if (task.isSuccessful){ toast("Login successful") } else { toast("Invalid Credentials Or User Not Registered") } } }
No comments:
Post a Comment