Override 'Login Forbidden' error message in meteor-useraccounts

你说的曾经没有我的故事 提交于 2019-12-13 20:12:39

问题


I have built a basic Telescope Application. When I enter a wrong password it displays the error message 'Login Forbidden'. I want to change the error message something relevant to the action. Where and what code should I include to make the changes?


回答1:


Instead of replacing the Accounts.validateLoginAttempt function, I recommend to configure a mapping via the meteor-accounts-t9n API (assuming you just want to replace the error message):

  1. Run meteor add softwarerero:accounts-t9n
  2. Add the following code:

if (Meteor.isClient) {
    T9n.map('en', {
        error: {
            accounts: {
                'Login forbidden': 'Credentials are incorrect!'
            }
        }
    });
}



回答2:


I'm assuming you are using Meteor's Accounts package, since you haven't indicated otherwise. You can override the Accounts.validateLoginAttempt function (docs), to throw a Meteor.Error. As written in the docs:

A validate login callback must return a truthy value for the login to proceed. > If the callback returns a falsy value or throws an exception, the login is > aborted. Throwing a Meteor.Error will report the error reason to the user.



来源:https://stackoverflow.com/questions/31941460/override-login-forbidden-error-message-in-meteor-useraccounts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!