FireBaseauth:Update(未在用户中签名)密码不使用'sendpasswordresetemail'

问题描述 投票:0回答:2

我知道如何更新firebase auth中用户中的密码:

var user = firebase.auth().currentUser; //get current connected user return user.updatePassword(newPass) .then( () => //success ) .catch(error => this.handleError(error)) }
但我不知道如何使用在用户

中签名的。也许只有像这样的电子邮件检索用户验证持久性(但没有办法这样做):

var user = firebase.auth().getUserByEmail(email); //not implmented in auth firebase
PS:我不想使用该方法

sendpasswordresetemail()

var auth = firebase.auth(); return auth.sendPasswordResetEmail(email);
非常感谢帮助,
谢谢!

javascript firebase firebase-authentication
2个回答
0
投票
仅允许将密码重置(和其他消息)发送给当前在用户中的签名,因为任何其他呼叫都将是主要的滥用向量。因此,无法仅根据其电子邮件地址将密码重置消息发送给用户。

如果您想要此功能,则必须自己实施。在过程结束时,您可以使用firebase admin SDK来用户配置文件中的密码

另外,请参见:

Firebase:如何使用nodejs

发送密码重置电子邮件后端
  • 在服务器/admin创建帐户后,请发布firebase重置密码电子邮件
  • 从“ firebase/auth”中添加“ auth”为null,但“电子邮件”与您的一个用户匹配,将导致发送给他们的电子邮件与用户登录一样,并且“ auth”当前使用者
  • await sendPasswordResetEmail(auth, email);

0
投票
// ForgotPassword.js import React, { useState } from "react"; import { sendPasswordResetEmail } from "firebase/auth"; import { Link, useNavigate } from "react-router-dom"; import { auth } from "../firebaseConfig"; const ForgotPassword = () => { const [email, setEmail] = useState("[email protected]"); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const navigate = useNavigate(); const handleSubmit = async (e) => { e.preventDefault(); setError(null); try { setLoading(true); await sendPasswordResetEmail(auth, email); alert("Check your email for a password reset link."); navigate("/"); } catch (error) { console.error("Error during authentication:", error.message); setError(error.message); } setLoading(false); }; return ( <div> <h2>New Forgot Password</h2> {error && <p style={{ color: "red" }}>{error}</p>} <form onSubmit={handleSubmit}> <div> <label>Email:</label> <input type="email" value={email} onChange={(e) => setEmail(e.target.value)} required /> </div> <button disabled={loading} type="submit"> {"Reset Password"} </button> <Link to="/Login">Back to Login</Link> </form> </div> ); }; export default ForgotPassword;

	

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.