慕仙森
2023-07-20 14:50:05
我正在嘗試發(fā)送與 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,};這是我的郵件發(fā)送功能。它接受我需要將電子郵件發(fā)送到的電子郵件。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 ......}我應該將位置放在哪里才能將位置與電子郵件一起發(fā)送。
1 回答

犯罪嫌疑人X
TA貢獻2080條經(jīng)驗 獲得超4個贊
actionCodeSettings
如果我正確理解您的問題,您應該在作為方法的第二個參數(shù)傳遞的對象中傳遞“繼續(xù) 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
提交
取消