我已在我的本机应用程序中从firebase启用signInWithEmailLink()
。>
一切都成功进行,还创建了用户,但是我认为onLink(handleLink)
侦听器被多次触发,甚至在用户登录后也会导致错误。
日志:
link is tru LOG email: [email protected] //I have hidden the actual email LOG email: [email protected] LOG email: [email protected] LOG USer created LOG EROR: [Error: [auth/invalid-action-code] The out of band code is invalid. This can happen if the code is malformed, expired, or has already been used.] LOG EROR: [Error: [auth/invalid-action-code] The out of band code is invalid. This can happen if the code is malformed, expired, or has already been used.] LOG EROR: [Error: [auth/invalid-action-code] The out of band code is invalid. This can happen if the code is malformed, expired, or has already been used.]
您可以看到它多次被触发,如何防止这种情况呢?
这是我的代码:
const handleLink = async link => { console.log('opened Link: ', link.url); if (auth().isSignInWithEmailLink(link.url)) { console.log('link is tru'); try { const email = await AsyncStorage.getItem('email'); console.log('email: ', email); await auth() .signInWithEmailLink(`${email}`, link.url) .then(() => { console.log('USer created'); }) .catch(err => { console.log('EROR: ', err); }); } catch (err) { console.log('err: ', err); } } else { console.log('link is false'); } }; const link = dynamicLinks().onLink(handleLink);
非常感谢您的帮助
我已在我的本机应用程序的firebase中启用signInWithEmailLink()。一切都成功完成,还创建了用户,但是我认为onLink(handleLink)侦听器被触发了多个...
由于console.log('email: ', email);
被调用了3次,所以我假设console.log('link is tru');
也被调用了3次,所以问题是整个handleLink
函数在auth().signInWithEmailLink
完成之前被调用了3次。