新用户可以访问其他用户

时间:2016-09-16 19:53:45

标签: android firebase firebase-storage

这些是我的Firebase存储规则。

match 
/{allPaths=**} {
     allow read, write: if request.auth != null;

这是用户将图片添加到存储空间的方式

StorageReference filepathOne = mStorage.child(user_data.getString("uidkey", null)).child("Photos").child("id_one");

如您所见,我正在使用UID作为文件路径名称的一部分。我的假设是,每当用户上传他们想要的图片时,只有他们能够访问它,因为他们拥有唯一的UID。但是,我创建了一个新的用户帐户,出于某种原因,该用户可以访问其他用户上传的照片,即使他们有不同的UID。

我还应该指出,我将URI存储在sharedpref中,然后将其转换为字符串以使其显示图片。

这是我存储在SharedPref中的方式

Uri downloadUrl = taskSnapshot.getDownloadUrl();                        

Picasso.with(getContext())
    .load(downloadUrl)
    .fit().centerCrop()
    .into(image);

editor.putString(user_idone, (taskSnapshot.getDownloadUrl()).toString());                             
editor.commit();

这是我从Pref中提取并显示的方式。

Picasso.with(getContext())
    .load(Uri.parse(user_data.getString("idonekey", null)))
    .fit().centerCrop()
    .into((ImageView) getView().findViewById(R.id.image));

0 个答案:

没有答案
相关问题