Meteor通过不同的服务器登录

Meteor通过不同的服务器登录,meteor,react-native,Meteor,React Native,我想让我的meteor用户通过我的react本机应用程序登录 我有一个网站是由Meteor/reactjs创建的,另一个是使用android react native的应用程序,它们共享同一个Mongo数据库。 我的meteor网站使用bcrypt(meteor帐户密码),我的react本机应用程序尝试使用SHA256和bcrypt,因此当我通过连接到数据库的react本机应用程序登录时,哈希密码不匹配,我得到一个错误 我只是对如何散列我的react原生密码以使其与meteor用户的散列密码匹配

我想让我的meteor用户通过我的react本机应用程序登录

我有一个网站是由Meteor/reactjs创建的,另一个是使用android react native的应用程序,它们共享同一个Mongo数据库。 我的meteor网站使用bcrypt(meteor帐户密码),我的react本机应用程序尝试使用SHA256和bcrypt,因此当我通过连接到数据库的react本机应用程序登录时,哈希密码不匹配,我得到一个错误

我只是对如何散列我的react原生密码以使其与meteor用户的散列密码匹配感到困惑。任何帮助都很好,干杯

这是前端

   sendAjax = () => {

   const m = encodeURIComponent(this.state.email);
    const p = encodeURIComponent(this.state.password);
    const hashDigest = sha256(p);
    const requestBody = `email=${m}&password=${hashDigest}&mphone`;
    //POST
    fetch("http://**************/users/auth", {
        method: "POST",
        mode: "cors",
        headers: {
            "Accept": "application/json",  
           "Content-Type": "application/x-www-form-urlencoded"
        },
        body: requestBody
    }).then(function (res, next) {
        console.log("fetch request ", JSON.stringify(res.ok));
        if(res.ok){
            res.json().then(function (json) {
                console.info(json);
                console.info(json.verifystate);
                if(json.verifystate){
                    Alert.alert("Login success");
                    Actions.leaderBoard();
                }else{
                    Alert.alert("Login fail, please try again");
                }
            });
        }else{
            Alert.alert('Noted','request failed',[{text: 'confirm', onPress: () => console.log('OK Pressed!')},]);
            next();
        }
    })
    .catch(function (e) {
        console.log("fetch fail");
        Alert.alert('Noted','system error',[{text: 'confirm', onPress: () => console.log('OK Pressed!')},]);
    });
   }
这是我的后端

   app.post('/users/auth', function(req, res) {
        loginData(db, req.body.email, req.body.password, function(result){
          if(result == 1){
            console.log("find the result!");
            res.send({"verifystate":true});
          }else{
            console.log('cannot find it');
          }
        });    
   });
  ......
  var loginData = function(db, email, myPlaintextPassword, mphone, callback){
var collectionUser = db.collection('users');
bcrypt.genSalt(saltRounds, function(err, salt) {
    bcrypt.hash(myPlaintextPassword, salt, function(err, hash) {

       var queryStr = {"emails.address": email, "services.password.bcrypt": hash};
        collectionUser.count(queryStr, function(err, result) {
            if(err)
            {
                console.log('Error2:'+ err);
            }
            callback(result);
        });
    });
});

})

您是否为您的react native应用程序使用react native meteor软件包?您的RN应用程序是否有后端?它如何连接到数据库?你能发布你用来验证密码的代码吗?您是否正在尝试在客户端(RN运行时)上使用bcrypt?您好,我已经更新了我的帖子以包含前端和后端代码。我也在寻找相同的答案,因为我正在尝试使用Nativescript(类似于React Native)构建一个应用程序,并希望它登录。我还没有实现它,但根据我的阅读资料,使用JWT可能会有所帮助。您是否为您的react native应用程序使用react native meteor软件包?您的RN应用程序是否有后端?它如何连接到数据库?你能发布你用来验证密码的代码吗?您是否正在尝试在客户端(RN运行时)上使用bcrypt?您好,我已经更新了我的帖子以包含前端和后端代码。我也在寻找相同的答案,因为我正在尝试使用Nativescript(类似于React Native)构建一个应用程序,并希望它登录。我还没有实现它,但根据我的阅读资料,使用JWT可能会有所帮助。