我正在尝试发送与 firebase 的身份验证链接。以下是 firebase 文档中的代码。export const CODE_SETTINGS = { // URL you want to redirect back to. The domain (www.example.com) for this // URL must be in the authorized domains list in the Firebase Console. url: 'http://localhost:3000/finishedSignUp', handleCodeInApp: true,};这是我的邮件发送功能。它接受我需要将电子邮件发送到的电子邮件。export const startEmailAuth = (email: string) => { firebase .auth() .sendSignInLinkToEmail(email, ACTION_CODE_SETTINGS) .then(function(result) { // The link was successfully sent. Inform the user. // Save the email locally so you don't need to ask the user for it again // if they open the link on the same device. window.localStorage.setItem('emailForSignIn', email); // TODO: make a nicer UI here. alert(`Verification email has been sent to ${email}`); }) .catch(function(error) { console.error(error); });};我的问题是,如果我将代码更改为这样的内容。export const startEmailAuth = (email: string, location: string) => { firebase ......}我应该将位置放在哪里才能将位置与电子邮件一起发送。
1 回答
犯罪嫌疑人X
TA贡献2080条经验 获得超4个赞
actionCodeSettings
如果我正确理解您的问题,您应该在作为方法的第二个参数传递的对象中传递“继续 url”值,
更准确地说,您需要将此值分配给对象url
的属性actionCodeSettings
。用于window.location.pathname
构建此值。
export const startEmailAuth = (email: string, location: string) => {
const ACTION_CODE_SETTINGS = {
url: location,
// ....
};
firebase
.auth()
.sendSignInLinkToEmail(email, ACTION_CODE_SETTINGS)
.then(function (result) {
// ...
})
.catch(function (error) {
console.error(error);
});
};
添加回答
举报
0/150
提交
取消