当我在 ionic 中输入电子邮件时,我想从 firebase 获取用户 ID
I want to get the userid from firebase when i enter the email in ionic
我正在设置搜索方法。所以我想在输入 email 时从身份验证中获取 userid 特定帐户。
注意 : 我已经使用 createUserWithEmailAndPassword 方法注册了用户..
为了使用搜索功能,您需要所有用户的列表。并且可以通过邮箱获取用户的uid。
您可以使用 firebase admin sdk 来完成此操作。
https://firebase.google.com/docs/auth/admin/manage-users
它有一个 listusers 功能:
admin.auth().listUsers(1000, nextPageToken)
.then(function(listUsersResult) {
listUsersResult.users.forEach(function(userRecord) {
console.log('user', userRecord.toJSON());
});
if (listUsersResult.pageToken) {
// List next batch of users.
listAllUsers(listUsersResult.pageToken);
}
})
.catch(function(error) {
console.log('Error listing users:', error);
});
还有getuserbyemail功能:
admin.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);
});
我正在设置搜索方法。所以我想在输入 email 时从身份验证中获取 userid 特定帐户。
注意 : 我已经使用 createUserWithEmailAndPassword 方法注册了用户..
为了使用搜索功能,您需要所有用户的列表。并且可以通过邮箱获取用户的uid。
您可以使用 firebase admin sdk 来完成此操作。 https://firebase.google.com/docs/auth/admin/manage-users
它有一个 listusers 功能:
admin.auth().listUsers(1000, nextPageToken)
.then(function(listUsersResult) {
listUsersResult.users.forEach(function(userRecord) {
console.log('user', userRecord.toJSON());
});
if (listUsersResult.pageToken) {
// List next batch of users.
listAllUsers(listUsersResult.pageToken);
}
})
.catch(function(error) {
console.log('Error listing users:', error);
});
还有getuserbyemail功能:
admin.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);
});