【发布时间】:2017-12-26 07:02:15
【问题描述】:
我有一个使用 Firebase 的注册流程。当我检查数据库中是否已经存在电子邮件时,如下所示:
refUsers.queryOrdered(byChild: "email").queryEqual(toValue: emailText).observeSingleEvent(of: .value, with: { snapshot in
if (snapshot.value is NSNull) {
print("Unique email")
// Move to Password View.
let passwordViewController = self.storyboard?.instantiateViewController(withIdentifier: "PasswordViewController") as! PasswordViewController
self.navigationController?.present(passwordViewController, animated: true, completion: nil)
// Pass the emailText to the last View of the flow.
self.singleton.sharedInstance.emailText = emailText!
}
else {
print("Duplicate email")
}
})
问题是,我没有权限查看数据库中的/users,因为我的规则是:
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
我知道我可以使用 Auth.auth().createUser 查找电子邮件是否重复,但我在注册流程中检查的不仅仅是电子邮件。我也对唯一用户名使用相同的方法。我怎样才能做到这一点?
【问题讨论】:
标签: ios swift firebase firebase-realtime-database firebase-authentication