我试图通过Supabase登录,但收到错误:
react_devtools_backend.js:2655 Error: _supabaseClient__WEBPACK_IMPORTED_MODULE_2__.default.auth.signIn is not a function
overrideMethod @ react_devtools_backend.js:2655
handleLogin @ AuthModal.js:38
onSubmit @ AuthModal.js:77
callCallback @ react-dom.development.js:4164
invokeGuardedCallbackDev @ react-dom.development.js:4213
invokeGuardedCallback @ react-dom.development.js:4277
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:4291
executeDispatch @ react-dom.development.js:9041
processDispatchQueueItemsInOrder @ react-dom.development.js:9073
processDispatchQueue @ react-dom.development.js:9086
dispatchEventsForPlugins @ react-dom.development.js:9097
(anonymous) @ react-dom.development.js:9288
batchedUpdates$1 @ react-dom.development.js:26140
batchedUpdates @ react-dom.development.js:3991
dispatchEventForPluginEventSystem @ react-dom.development.js:9287
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ react-dom.development.js:6465
dispatchEvent @ react-dom.development.js:6457
dispatchDiscreteEvent @ react-dom.development.js:6430
文档说,这实际上是一个函数,我正在使用与它非常相似的代码来注册,注册代码工作得很好。
下面是我的代码:
const email = useRef();
const password = useRef();
const handleLogin = async (email, password) => {
try {
const { user, error } = await supabase.auth.signIn({
email: email,
password: password,
})
if (error) {
if (error.message === 'Email not confirmed') {
setError('Please check your email and confirm your address before logging in.');
} else {
console.error('Error during sign in:', error.message);
}
} else {
console.log('User signed in:', user);
onLogin(); // Call the onLogin prop here
}
} catch (error) {
console.error('Error:', error.message);
}
};
const { user, session, error } = await supabase.auth.signIn({
email: 'example@email.com',
password: 'example-password',
})
任何帮助都将不胜感激。谢谢。
1条答案
按热度按时间6vl6ewon1#
我用的是v1的docs但是v2的supabase。
将supabase.auth.SignIn更改为
supabase.auth.SignInWithPassword
修好了。