如何阻止在 Firebase 中的一台设备上创建多个帐户?

问题描述 投票:0回答:1

我创建了应用程序,但问题是用户可以在一台设备上创建多个帐户,这破坏了应用程序的整体目的。如何让应用程序检查 firestore 中的数据并将其与当前数据进行比较?

   private void storeUserData(String name, String email, String password) {

        auth.createUserWithEmailAndPassword(binding.edtemail.getText().toString(),binding.edtpassword.getText().toString()).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {

                if (task.isSuccessful()) {

                    progressDialog.dismiss();

                    String referCode = email.substring(0,email.lastIndexOf("@"));
                    String Deviceid = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
                    UserModel model = new UserModel(name,email,password,
                            "https://firebasestorage.googleapis.com/v0/b/cashapp-278ce.appspot.com/o/plac.png?alt=media&token=61f99d71-5ada-47f0-b72a-9b69e4e32471",
                            referCode,
                            Deviceid,
                            "false",
                            5,
                            5,
                            5);
                    String id = task.getResult().getUser().getUid();

                    firestore.collection("Users").document(id).set(model).addOnCompleteListener(new OnCompleteListener<Void>() {
                        @Override
                        public void onComplete(@NonNull Task<Void> task) {

                            if (task.isSuccessful()){

                                Intent intent = new Intent(SignupActivity.this,MainActivity.class);
                                startActivity(intent);
                                finish();

enter image description here

firebase google-cloud-firestore firebase-authentication public
1个回答
0
投票

我认为您正在寻找阻止功能。有一个

beforeCreate
函数可以帮助您甚至在创建用户之前运行和使用一些逻辑。因此,您可以执行任何您想要的逻辑,甚至可以在 Firestore 数据库中搜索 Android ID 是否存在。

© www.soinside.com 2019 - 2024. All rights reserved.