Не буду долго ходить вокруг до около: Проблема с firestore и auth. Ошибка с разрешениями
Error: [firestore/permission-denied] The caller does not have permission to execute the specified operation. NativeFirebaseError: [firestore/permission-denied] The caller does not have permission to execute the specified operation.
Правила прописаны в FireStore:
rules_version = '2';
service cloud.firestore {
match/databases/{database}/documents {
match /Users/{document=**} {
allow read, get: if true;
allow create, update: if request.auth.uid == resource.id;
}
}
Используются следующие библиотеки
- @react-native-firebase/app
- @react-native-firebase/app-check
- @react-native-firebase/auth
- @react-native-firebase/firestore
И сам код:
import auth from '@react-native-firebase/auth';
import firestore from '@react-native-firebase/firestore';
async function onAuthChanged(onChange) {
auth().onAuthStateChanged(onChange);
}
async function authenticateUser(status) {
// Получаем значение вошел в систему или вышел пользователь из системы.
// Не из окна D
if (status) {
// Пользователь вошел в систему / пользователь уже был в системе
const uid = status.uid;
// По uid ищем пользователя в firestore и меняем состояние компонента
let user = await firestore().collection('Users').doc(uid).get(); // Ошибка происходит на данной строке
// Если документ с uid пользователя не будет найден в firestore, то он автоматически создаться
return ({
user: {...user.data(), uid} ?? {login: undefined, birthday: undefined, uid}
});
} else {
// Пользователь вышел из системы / пользователя не было в системе
return { user: null };
}
}
onAuthChanged(async (status) => {
const { user } = await authenticateUser(status);
});
P.S. В fireStore: правила работают enter image description here
P.S.S Вариант, которые говорят просто поставить
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
это не помогает все равно