firebase:如何链接电子邮件验证和密码

时间:2018-07-23 07:27:49

标签: android firebase react-native firebase-authentication

我已经使用电子邮件和密码对用户进行身份验证,但是我想在React Native中使用Firebase添加电子邮件链接验证。

因此,用户必须提供他/她拥有的正确的电子邮件地址和密码,如何链接或创建它们。

这是我的注册代码:

export const signupUser = ({firstName, lastName, userName, email, password}) => async dispatch => {
    dispatch({ type: SIGNUP_SPINNER });
    try {
        let user = await firebase.auth().createUserWithEmailAndPassword(email, password);
        if(user) {
            const { currentUser } = firebase.auth();
            // add displayName 
            await currentUser.updateProfile({
                displayName: `${firstName} ${lastName}`
            });
            await firebase.database().ref(`/users/${currentUser.uid}/profile`)
                .push({firstName, lastName, userName, email})
                .then(async () => {
                    dispatch({ type: SIGNUP_INITIAL_STATE });
                });
        }
    } catch(err) {
        dispatch({ type: SIGNUP_USER_FAIL, payload: 'something went wrong, please try again!!!' });
    }
}

1 个答案:

答案 0 :(得分:0)

可以通过多种方式在移动应用中完成电子邮件验证:

  1. 让用户通过手机上的本机帐户登录 (https://github.com/react-native-community/react-native-google-signin)。 如果用户能够通过Google登录,则表明他是该网站的合法用户 帐户
  2. 发送电子邮件 (Sending automated emails from Firebase through Google Cloud Platform (no third parties)) 与链接一样 https://yourserver.com/?token=和 如果用户打开此链接,请激活电子邮件。在这种情况下,您需要 您在服务器上自己的脚本。
  3. 发送电子邮件 (Sending automated emails from Firebase through Google Cloud Platform (no third parties)) 与链接一样 yourScheme:// verification?token和 在您的设备上处理此方案并通过以下方式验证帐户 端点。它的安全性较差,但不需要服务器。
相关问题