亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 firebase 身份驗證電子郵件中發送 window.location.pathname

如何在 firebase 身份驗證電子郵件中發送 window.location.pathname

慕仙森 2023-07-20 14:50:05
我正在嘗試發送與 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);

? ? ? });

? };


查看完整回答
反對 回復 2023-07-20
  • 1 回答
  • 0 關注
  • 167 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號