[英]Getting Anonymous user when creating user with firebase admin sdk
我遇到的問題是,當我使用 firebase admin sdk 創建用戶時,該用戶被創建為匿名用戶。 數據來自 angular 到 node.js,用戶甚至是創建的,但是是匿名的。
這是代碼
const post = req.body;
admin.auth().createUser({
email: post.email,
password: post.password
}).then((userRecord) => {
console.log('Successfully created new user:', userRecord.uid);
})
.catch((error) => {
console.log('Error creating new user:', error);
});
當通過管理員 SDK 創建用戶時,它只是一個 Firebase 身份驗證用戶配置文件。 它不依賴於任何特定的提供者。
要使用任何特定提供商創建用戶帳戶,
您必須在 Firebase Project > Authentication > Sign-in method 中啟用登錄提供程序
使用Firebase SDK
認證 - https://firebase.google.com/docs/auth/web/start
例如,如果您希望使用電子郵件/密碼提供商創建用戶,
Email/Password
提供程序firebase.auth().createUserWithEmailAndPassword(email, password)
.then((userCredential) => {
// Signed in
var user = userCredential.user;
// ...
})
.catch((error) => {
var errorCode = error.code;
var errorMessage = error.message;
// ..
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.