i just writing a error notification panel in meteor, here i create a client side mongodb, but i cant push Meteor.Error message in to that client side db by throwError function, currently it's shows inside an alert box

我只是在meteor中写了一个错误通知面板,在这里我创建了一个客户端mongodb,但我不能通过throwError函数将Meteor.Error消息推送到该客户端db,目前它显示在一个警告框内

collection/signup.js

收集/ signup.js

signupDB = new Meteor.Collection('signup');

Meteor.methods({

    signupSubmit : function(postData) {

        var signinEmailExist = signinDB.findOne({
        email : postData.email
        });

        if (postData.email && signinEmailExist)
        throw new Meteor.Error(422, "exist in signinDB");

        var signupEmailExist = signupDB.findOne({
        email : postData.email
        });

        if (postData.email && signupEmailExist)
        throw new Meteor.Error(422, "exist in signupDB");       //    

        var user = _.extend(_.pick(postData, 'email', 'password'), {
            insert_time : new Date().getTime()      });

        var userId = signupDB.insert(user);

        return userId;

    }

});

client/error/error.js

客户端/错误/ error.js

errorDB = new Meteor.Collection(null);

throwError = function(data) {
    errorDB.insert({data: "in throwError", del: "N"})
}

errorDB.insert({data: "in signup", del: "N"}) code is working anywhere inside client folder

errorDB.insert({data:“in signup”,del:“N”})代码在客户端文件夹内的任何位置工作

here throwError function can't called, but signupSubmit method errors shows in a alert box

这里throwError函数无法调用,但signupSubmit方法错误显示在警告框中

is the problem of publication/subscription like thinks (not wrote for signup db) ?

像think一样出版/订阅的问题(不是为注册数据库写的)?

how i catch and insert Meteor.Error alerts From Meteor.Methods in to a client side db ?

我如何捕获并插入Meteor.Error警报从Meteor.Methods到客户端数据库?

is there any other function like throwError to trap Meteor.Methods errors ?

有没有像throwError这样的其他函数来捕获Meteor.Methods错误?

1 个解决方案

#1


3

How are you calling the method? You need to do something like:

你怎么称呼这个方法?你需要做一些事情:

Meteor.call('signupSubmit', user, function(err) {
  errorDB.insert(err);
});

However, you seem to be implementing a custom, insecure authentication system. You shouldn't do this; Meteor has a great, secure built-in Accounts package. All you need to do is (on the client side):

但是,您似乎正在实施自定义,不安全的身份验证系统。你不应该这样做; Meteor有一个很棒的,安全的内置帐户包。您需要做的就是(在客户端):

errors = new Meteor.Collection;

Accounts.createUser({
  email: email,
  password: password
}, function(err) {
  errors.insert(err);
});

The Accounts.createUser method automatically returns an error if the username/email is duplicated.

如果用户名/电子邮件重复,Accounts.createUser方法会自动返回错误。

更多相关文章

  1. 键盘出现时,UIWebView滚动。导致点击偏移错误?
  2. 关于洗牌算法的错误认识
  3. JSON.parse(xhr.responseText)意外的字符串错误
  4. 当尝试安装节点时,会得到一个“DLL”错误。js在Windows 7上
  5. VBA中的错误处理
  6. 错误地将JSON数据写入文件。
  7. jquery ajax readystate 0 responsetext status 0 stext错误
  8. 为什么我收到此错误:“未捕获的TypeError:无法读取未定义的属性'标
  9. 如何避免pro拖拉机中的“jasmin .suite() required”错误消息?

随机推荐

  1. classmethod,staticmethod,还有类里面一般
  2. Python文件操作大全,随机删除文件夹内的任
  3. 获取错误“ValueError:int()的无效文字,基数
  4. C++各大有名库的介绍——准标准库Boost
  5. 从Python中的列表元素中删除URL
  6. python传递列表作为函数参数
  7. Python读取修改ini配置文件[ConfigParser
  8. 用 Opencv 和 Python 对狗狗做模糊检测
  9. python-条件语句练习
  10. Python执行系统命令:使用subprocess的Pope