firebase:错误(auth/auth/invalid-value-(电子邮件),在标量字段上启动对象
我是第一次将firebase实施到我的应用程序中。我正在收到此错误:
“ firebase:error(auth/invalid-value-(email), - 启动 - an-abject-on-a-a-Scalar-calar-field-field-invalid-value-(密码), - 启动an-abobject - 在阵地场上)。
我的代码:
compistersCreen.js
import { auth } from '../firebase'
import { createUserWithEmailAndPassword } from "firebase/auth";
export default function RegisterScreen({ navigation }) {
const [name, setName] = useState({ value: '', error: '' })
const [email, setEmail] = useState({ value: '', error: '' })
const [password, setPassword] = useState({ value: '', error: '' })
const handleSignUp =() => {
const nameError = nameValidator(name.value)
const emailError = emailValidator(email.value)
const passwordError = passwordValidator(password.value)
if (emailError || passwordError || nameError) {
setName({ ...name, error: nameError })
setEmail({ ...email, error: emailError })
setPassword({ ...password, error: passwordError })
return
}
auth
createUserWithEmailAndPassword(auth, email, password)
.then(userCredentials => {
const user = userCredentials.user;
console.log(user.email)
})
.catch(error => alert(error.message))
}
firebase.js
// Import the functions you need from the SDKs you need
import * as firebase from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyA1zo9ci0RXQYBNUooGtSK2b29OPxOC0GE",
authDomain: "aslassistfinal.firebaseapp.com",
databaseURL: "https://aslassistfinal-default-rtdb.firebaseio.com",
projectId: "aslassistfinal",
storageBucket: "aslassistfinal.appspot.com",
messagingSenderId: "380652280816",
appId: "1:380652280816:web:5f49bf6df4977cdb401b35",
//measurementId: "G-TYX10C1CBE"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
export { auth }
我在文档中找不到此错误 A>
我已经确认我用来验证的电子邮件和密码有效。
预先感谢您的任何帮助,如果您需要其他任何信息,请告诉我。
I am implementing firebase into my application for the first time. I am receiving this error:
"Firebase: Error (auth/invalid-value-(email),-starting-an-object-on-a-scalar-field-invalid-value-(password),-starting-an-object-on-a-scalar-field)."
My code:
registerscreen.js
import { auth } from '../firebase'
import { createUserWithEmailAndPassword } from "firebase/auth";
export default function RegisterScreen({ navigation }) {
const [name, setName] = useState({ value: '', error: '' })
const [email, setEmail] = useState({ value: '', error: '' })
const [password, setPassword] = useState({ value: '', error: '' })
const handleSignUp =() => {
const nameError = nameValidator(name.value)
const emailError = emailValidator(email.value)
const passwordError = passwordValidator(password.value)
if (emailError || passwordError || nameError) {
setName({ ...name, error: nameError })
setEmail({ ...email, error: emailError })
setPassword({ ...password, error: passwordError })
return
}
auth
createUserWithEmailAndPassword(auth, email, password)
.then(userCredentials => {
const user = userCredentials.user;
console.log(user.email)
})
.catch(error => alert(error.message))
}
firebase.js
// Import the functions you need from the SDKs you need
import * as firebase from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyA1zo9ci0RXQYBNUooGtSK2b29OPxOC0GE",
authDomain: "aslassistfinal.firebaseapp.com",
databaseURL: "https://aslassistfinal-default-rtdb.firebaseio.com",
projectId: "aslassistfinal",
storageBucket: "aslassistfinal.appspot.com",
messagingSenderId: "380652280816",
appId: "1:380652280816:web:5f49bf6df4977cdb401b35",
//measurementId: "G-TYX10C1CBE"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
export { auth }
I cannot find this error in the documentation found here
I have confirmed that the email and password I am using to authenticate is valid.
Thank you in advance for any help and if you need any other info let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您会遇到此错误,因为“电子邮件”是在此处初始化为对象的,该对象由 value & 错误 AS 2字符串 - const [email,seteMail] = usestate({ value:'',错误:''})
firebase auth是在 createUserwithemailandpassword(auth,email,passwass)中期望字符串值方法,因此您需要使用 email.value 而不是 电子邮件 &密码也是如此。
另一个提示 - 您可能还想从此处删除Firebase凭据(firebase.js),因为它们可能会被滥用
You were getting this error because 'email' was initialized as an object here which comprised of value & error as 2 strings - const [email, setEmail] = useState({ value: '', error: '' })
Firebase auth is expecting string values in createUserWithEmailAndPassword(auth, email, password) method so you need to use email.value instead of just email & same goes for password as well.
ANOTHER TIP - you might also want to remove your firebase credentials from here (firebase.js) as they might get misused
回答我自己的问题:
在我的状态下,我有
:在我的输入场中,
我仍然不确定错误的确切含义是什么,但是我将我
的输入字段更改为:
现在我没有问题。尽管我想在状态管理中设置错误,但我将围绕它进行工作并做其他事情。
Answering my own question:
In my state I had:
In my inputfields I had:
I am still unsure what the exact meaning of the error is but I changed my state to:
And my input fields to:
And now I am having no problems. Although I wanted to set error's in my state management, I will just work around it and do something else.