Using the replace function in firestore security rules

后端 未结 3 518
醉梦人生
醉梦人生 2021-01-16 10:49

I\'m struggling with Firestore security rules. I want to check on a value that needs the replace function, i.e. an e-mail address. I can find some documentation in the gener

3条回答
  •  醉酒成梦
    2021-01-16 11:14

    There are two reasons why you might have been having issues.

    1. The replace function was added to Security Rules after you asked your question.
    2. The replace function uses regular expressions for the first argument and so matching on '.' will match literally everything.

    Consider instead using: request.auth.token.email.replace('\\.' , ',')

提交回复
热议问题