I am developing an app which has different user types (User and Admin) and privileges based on their custom claims in Firebase Realtime DB.
I want a button to be visible only if the user is admin.
firebaseUser?.getIdToken(false)?.addOnSuccessListener { user ->
val isAdmin = user.claims["admin"]
if (isAdmin == true) {
binding.btnOnlyAdminActivity.setOnClickListener {
val intent = Intent(context, OnlyAdminActivity::class.java)
startActivity(intent)
}
} else {
binding.btnOnlyAdminActivity.visibility = View.GONE
}
}
The code above works fine, but I wonder if this approach would arise a security problem such as a regular user detects that there is a gone button and clicks that somehow.