【问题标题】:firebase: how to link email verification and passwordfirebase:如何链接电子邮件验证和密码
【发布时间】:2018-12-30 14:21:11
【问题描述】:

我已经使用电子邮件和密码对用户进行身份验证,但我想在 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!!!' });
    }
}

【问题讨论】:

    标签: android firebase react-native firebase-authentication


    【解决方案1】:

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

    1. 让用户通过手机自带的本机账号登录 (https://github.com/react-native-community/react-native-google-signin)。 如果用户能够通过谷歌登录意味着他是合法用户 帐号
    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 和 在您的设备上处理此方案并通过以下方式验证帐户 端点。它不太安全,但您不需要服务器。

    【讨论】:

    • 实际上我想要这样的事情:1)使用电子邮件和密码注册 2)电子邮件链接验证 3)当电子邮件验证时,用户可以使用他们提供的电子邮件和密码登录。所以有两个身份验证。一个是邮箱和密码,另一个是邮箱验证,那我怎么存档呢
    猜你喜欢
    • 2020-10-19
    • 2021-11-21
    • 2019-01-02
    • 1970-01-01
    • 2019-05-20
    • 2019-03-15
    • 2016-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多