This file contains hidden or 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
import fs from 'fs'; | |
import * as path from 'path'; | |
import {before,it} from "mocha" | |
const TEST_FIREBASE_PROJECT_ID = "test-firestore-rules-project"; | |
import { Data, DataRealEstateTypeEnum} from '../entities/ts/models/Data' | |
import { OfferStatus } from '../entities/ts/models/OfferStatus' | |
import { |
This file contains hidden or 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
rules_version = '2'; | |
service cloud.firestore { | |
match /databases/{database}/documents { | |
function isAuthenticated() { | |
return request.auth != null; | |
} | |
function isDefined(field) { | |
return field in request.resource.data |
This file contains hidden or 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
function getAllowedUser() { | |
return get(/databases/$(database)/documents/settings/allowedUsers) | |
} | |
function validUser() { | |
let allowedUsers = getAllowedUser(); | |
return request.auth.token.email in allowedUsers.data.emails | |
|| | |
request.auth.token.email.split("@")[1] in allowedUsers.data.domains | |
} |