Having problems validating if a user or account exist in this SaaS structure

23 views
Skip to first unread message

John Hamman

unread,
Apr 23, 2016, 10:37:43 AM4/23/16
to Firebase Google Group
Hi all, I am trying to test if an email exists AND also check if an account name exists before a new account is created.
The user will sign up on via website, which is connected to our API to handle custom AUTH and our API connects to Firebase via REST. Then the user can use the APP to connect to firebase after registration.

The service is a SaaS structured as written below. I am not sure I have it structured right, but each Account can have 1 owner (which has to be unique between all accounts), multiple sub-users, multiple sub items, etc. No data is shared between accounts. 

The question is, how can I check for an account name to see if it exists and the same for an email? Do I write this in an "rule" or is there a way I can query this via rest? 

{
  "accounts" : {
    "-KG2B4SsRi_lm7ZJ5lhs" : {
      "name" : "test",
      "users" : {
        "owner" : {
          "-KG2B4cVVMijoHBjQi58" : true
        }
      }
    },
    "-KG2IMmYvtbn_UrzAHWx" : {
      "name" : "test2",
      "users" : {
        "owner" : {
          "-KG2IMuUYRaEKrjpk-04" : true
        }
      }
    },
    "-KG2INKnzUMmFhYhgfx_" : {
      "name" : "test3",
      "users" : {
        "owner" : {
          "-KG2INT1VpHKPU3Pr6lM" : true
        }
      }
    }
  },
  
  "users" : {
    "-KG2B4cVVMijoHBjQi58" : {
      "account" : "-KG2B4SsRi_lm7ZJ5lhs",
      "email" : "1...@gmail.com",
      "password" : "$2y$10$gBooXLNAi6mz2LjkHvuSGetP5ni4zDt2KFv3BjbqeBL.rwp255zHy",
      "role" : "owner"
    },
    "-KG2IMuUYRaEKrjpk-04" : {
      "account" : "-KG2IMmYvtbn_UrzAHWx",
      "email" : "4...@gmail.com",
      "password" : "$2y$10$a/CC4MpXswSiIg4iXTeiGOkLzNJfX9Nf1qqq/qd40U6ANFvbM6uNm",
      "role" : "owner"
    },
    "-KG2INT1VpHKPU3Pr6lM" : {
      "account" : "-KG2INKnzUMmFhYhgfx_",
      "email" : "78...@gmail.com",
      "password" : "$2y$10$WB2vtecthm1OdEYK0hzJZOMBvxoyiRnMXIwOMbFLmQZW3cRfULwDC",
      "role" : "owner"
    }
  }
}

Kato Richardson

unread,
Apr 28, 2016, 3:54:28 PM4/28/16
to Firebase Google Group
Hi John,

Check out queries. You can run one using equalTo on name/email to fetch matches and see if they exist.

☼, Kato


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/1d6e906f-a02f-441b-9b10-ac6aeac02439%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages