简体   繁体   English

在 React 登录组件中,Firebase 登录注册正在运行,但是当我尝试发送重置密码链接时,则未发送到电子邮件

[英]In React Login component Firebase Login signup is working but when I am trying to send a reset password Link then is Not sending to email

In React Login component Firebase login signup is working but when I am trying to send a reset password Link then it is not working.在 React Login 组件中,Firebase 登录注册正在运行,但是当我尝试发送重置密码链接时,它无法正常工作。 there is no getting email value from the field, but sign-in is working.没有从该字段获取电子邮件值,但登录工作正常。 So unable to send the reset password link in my email.所以无法在我的电子邮件中发送重置密码链接。

Login Submit Button : it's working:登录提交按钮:它正在工作:

 const handleToSubmit = (event) => { event.preventDefault(); const email = event.target.email.value; const password = event.target.password.value; signInWithEmailAndPassword(email, password) }

Reset password Function code: it's not working:重设密码 功能码:无效:

<!-- language: lang-js -->

        const resetPassword = async (event) => {
            const email = event.target.email.value
            if (email) {
                await sendPasswordResetEmail(email);
                toast.success(`Check your Email ⮞ ${email}`);
            } else {
                toast.warn('Enter Email  ☹ ');
            }
        }

<!-- end snippet -->

My Email input field: it's working for login but not for reset password我的电子邮件输入字段:它可以用于登录,但不能用于重置密码

<Form.Group controlId="formBasicEmail">
      <Form.Control type="email" name="email" placeholder="Enter email" />
</Form.Group>

Reset Click Button: it's not working:重置单击按钮:它不起作用:


  
 
  
  
  
    <button onClick={resetPassword}> Reset Password </button>

I think you are using firebase v9.我认为您正在使用 firebase v9。

So you should pass auth as parameter to the function:所以你应该将auth作为参数传递给函数:

import { getAuth, sendPasswordResetEmail } from  "firebase/auth"; 

const auth = getAuth();
sendPasswordResetEmail(auth, email)
  .then(() => {
    // Password reset email sent!
    // show the toast
  })

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在这里,我尝试使用 firebase 身份验证登录,但出现 400 错误。 我给出了准确的 email 和密码,但它显示如下错误 - Here, I am trying to login using firebase auth, but getting 400 error. I am giving exact email & password but it's showing below error 如何将 state 从登录组件发送到反应中的 RequireAuth 组件? 我正在使用 React 路由器 - How to send state from Login component to RequireAuth component in react? I am using React router Firebase 用户注册 email 并通过 email 向他们发送密码 - Firebase user signup with email and send them password via email Firebase自定义密码重置链接不起作用 - Firebase custom password reset link not working 调用“发送密码重置电子邮件”方法时,防止Firebase出现“找不到电子邮件”错误 - Preventing “Email not found” error from Firebase when calling Send Password Reset Email method 尝试注册或登录时与 React.js 私有路由相关的问题 - React.js private route related issue when trying to signup or login firebase 前端安全登录和注册 - firebase login and signup in the frontend security 当我在 react 中选择登录或注册时如何隐藏导航栏? - How do I hide navbar when i select login or signup in react? jQuery弹出不登录/注册工作 - jquery popup not login/signup working Email 和在 React 应用程序中使用 firebase 的密码注册,用户的显示名称在初始渲染中显示为 null。 我怎样才能解决这个问题? - Email and Password Signup using firebase in a react app , the displayName of the user appears to be null on the initial render. How can I fix this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM