Created
October 14, 2019 22:52
-
-
Save mishra3452/ccf8fa5928d836f4d1a03eb06152f391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mindorks.firebaseloginsignup | |
import android.content.Intent | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.widget.Button | |
import android.widget.Toast | |
import com.google.firebase.auth.FirebaseAuth | |
class MainActivity : AppCompatActivity() { | |
private lateinit var auth: FirebaseAuth | |
private lateinit var logoutBtn: Button | |
private lateinit var updatePass: Button | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
auth = FirebaseAuth.getInstance() | |
if(auth.currentUser == null){ | |
val intent = Intent(this, LoginActivity::class.java) | |
startActivity(intent) | |
finish() | |
}else{ | |
Toast.makeText(this, "Already logged in", Toast.LENGTH_LONG).show() | |
} | |
setContentView(R.layout.activity_main) | |
logoutBtn = findViewById(R.id.logout_btn) | |
updatePass = findViewById(R.id.update_pass_btn) | |
logoutBtn.setOnClickListener{ | |
FirebaseAuth.getInstance().signOut() | |
val intent = Intent(this, LoginActivity::class.java) | |
startActivity(intent) | |
finish() | |
} | |
updatePass.setOnClickListener{ | |
val intent = Intent(this, UpdatePassword::class.java) | |
startActivity(intent) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment