[英]How to register a user whose email contains a capital letter in Firebase Authentication
[英]Firebase Authentication : Lookup a user by Email
我想知道我是否可以通过 email “查找”用户,同时也不能以用户身份登录
我想这样做的原因是,仅使用 email 地址来确定我是否已经是系统的用户
我查看了这个较旧的线程,但它似乎是 Firebase 的先前版本
是否可以在当前的 Firebase 中执行此操作,或者我的替代方法是保持此信息可用(并对所有人开放?)以确定给定的 email 是否是我系统的一部分?
我使用 fetchProvidersForEmail(email) ,如果结果返回为空数组,则该电子邮件尚未用于注册。
firebase.auth().fetchProvidersForEmail(email) .then(providers => { if (providers.length === 0) { // this email hasn't signed up yet } else { // has signed up } });
使用电子邮件密码创建用户的新方法会返回一个值,无论给定的电子邮件地址是否已被使用。 看这里
您可以通过电子邮件查找用户信息:
firebase.auth().getUserByEmail(email)
.then(function(userRecord) {
// See the UserRecord reference doc for the contents of userRecord.
console.log('Successfully fetched user data:', userRecord.toJSON());
})
.catch(function(error) {
console.log('Error fetching user data:', error);
});
服务器端选项:
https://cloud.google.com/identity-platform/docs/reference/rest/v1/projects.accounts/lookup
发布 https://identitytoolkit.googleapis.com/v1/projects/{targetProjectId}/accounts:lookup
{ "email": ["rodneydangerfield@stackoverflow.kom"] }
从 'firebase/auth' 导入 { fetchSignInMethodsForEmail }
fetchSignInMethodsForEmail(auth, registerEamil).then((result) =>{
console.log("result", result);
if (result.length === 0) {
Navigate("/authentication/select_role/" +
registerEamil)
} else {
Navigate('/')
}
至于今天2021年11月18日,Firebase SDK没有办法通过email来获取用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.