简体   繁体   English

Meteor修改auth智能包

[英]Meteor modify auth smart package

How do I modify the auth smart package? 如何修改auth智能包?

For example the dropdown box after registering show the buttons change password and sign out. 例如,注册后的下拉框显示按钮更改密码并注销。 I want to add an edit account button. 我想添加一个编辑帐户按钮。 How? 怎么样?

Thanks. 谢谢。

To add an edit button, look here: https://github.com/meteor/meteor/tree/master/packages/accounts-ui-unstyled 要添加编辑按钮,请在此处查看: https//github.com/meteor/meteor/tree/master/packages/accounts-ui-unstyled

Specifically, the login_buttons.html file. 具体来说,是login_buttons.html文件。

update: There's a note at the top of the linked file: 更新:链接文件顶部有一个注释:

NOTE: You shouldn't use these templates directly. 注意:您不应直接使用这些模板。 Instead, use the global {{loginButtons}} template. 而是使用全局{{loginButtons}}模板。

Thus, you should find these files in your meteor installation (mine is in C:\\Program Files (x86)\\Meteor\\packages\\accounts-ui\\login_buttons.html ) and edit that file. 因此,您应该在流星安装中找到这些文件(我的位于C:\\Program Files (x86)\\Meteor\\packages\\accounts-ui\\login_buttons.html )并编辑该文件。

Note this will modify the accounts UI for all your meteor apps. 请注意,这将修改所有流星应用程序的帐户UI。 If you do not want your changes to affect your other meteor apps, you will probably have to "fork" your own accounts-ui package. 如果您不希望您的更改影响您的其他流星应用程序,您可能需要“分叉”您自己的accounts-ui包。

There is discussion of making the accounts UI more customizable (like overridable templates), but it is not possible with the current version of Meteor. 讨论了使帐户UI更具可定制性(如可覆盖的模板),但目前的Meteor版本无法实现。 I suggest describing your use case to the meteor developers. 我建议向流星开发人员描述你的用例。 The meteor developers openly welcome feedback : 流星开发者公开欢迎反馈

Feedback, please! 反馈,拜托! Some specific areas that we're curious about: 我们很好奇的一些特定领域:

  • What sort of customization do you want to do to the loginButtons template? 您想对loginButtons模板进行哪种自定义?

  • What sort of account restrictions are you likely to use? 您可能使用哪种帐户限制? Everyone must have a username? 每个人都必须拥有用户名? Everyone must have an email? 每个人都必须有电子邮件?

You can override the loginButtons , because currently the default helpers object is public for some reason: 您可以覆盖loginButtons ,因为当前默认的帮助程序对象由于某种原因是公共的:

Handlebars._default_helpers["loginButtons"] = function(options) {
    return "hello this is test";
};

The original helper function looks like this: 原始辅助函数如下所示:

Handlebars.registerHelper(
  "loginButtons",
  function (options) {
    if (options.hash.align === "right")
      return new Handlebars.SafeString(Template._loginButtons({align: "right"}));
    else
      return new Handlebars.SafeString(Template._loginButtons({align: "left"}));
  });

Here you could replace the default _loginButtons template with your own. 在这里,您可以使用自己的模板替换默认的_loginButtons模板。

However this could easily break with a future version of meteor as Handlebars._default_helpers is not really intended to be used in that way. 然而,由于Handlebars._default_helpers实际上并不打算以这种方式使用,因此很容易打破未来版本的meteor。 But at least you don't have to work with a fork of meteor. 但至少你不必使用流星叉。

Also you have to make sure that you add your helper after accounts-ui-unstyled does. 此外,您必须确保在accounts-ui-unstyled后添加您的帮助程序accounts-ui-unstyled So if you are using this trick inside another package, be sure to declare accounts-ui-unstyled as a dependency. 因此,如果您在另一个包中使用此技巧,请确保将accounts-ui-unstyled声明为依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM