如何禁用流星帐户用户注册?

howto disable meteor accounts user registration?

我正在使用 meteor 帐户进行登录和用户注册。

当用户点击底线(注册)时:

他被重定向到创建帐户页面:

这些页面背后的代码混合了 jade 模板和 javascript。

template(name="userFormsLayout")
  section.auth-layout
    section.auth-dialog
      +Template.dynamic(template=content)

似乎在点击寄存器时内容被替换了 link 据我所知...

我想通过禁用注册页面上的最终注册按钮和/或禁用完整注册页面来阻止用户创建新帐户。

我也对其他阻止用户注册的解决方案持开放态度。

相关: How can I set forbidClientAccountCreation to false in Meteor?

更新: 我也试过这个

AccountsTemplates.configure({
  forbidClientAccountCreation: true

但得到了:

 Error: signUp route configured but forbidClientAccountCreation set to true!

谁能帮我解决这个问题?

我没有完整的答案,但我可以给你一些帮助你入门的东西。

首先,您可以告诉 AccountsTemplates (AT) 使用您的布局。你可以把它放在任何加载到客户端和服务器的地方,例如lib/atConfig:

AccountsTemplates.configureRoute('signIn', {
    layoutTemplate: 'LoginLayout'
});

这是布局模板:

<template name="LoginLayout">
    <main>
        <div>
            {{> Template.dynamic template=main}}
        </div>
    </main>
</template>

在 JS 中,您可以隐藏模板中不想让用户看到的部分。在这里,我隐藏了密码表单和分隔符。你可以深入 DOM 找出你想隐藏的位:

Template.LoginLayout.onRendered(function() {
    this.autorun(() => {
        if (this.subscriptionsReady()) {
            Tracker.afterFlush(() => {
                $('.at-pwd-form').remove();
                $('.at-sep').remove();
            });
        }
    });
});

对于服务器,您可以检查新用户的尝试,如果他们使用用户名和密码进行尝试,则拒绝他们。我认为这应该可行,但您可能需要尝试一下:

import {Meteor} from 'meteor/meteor';

Meteor.startup(() => {
    /**
     * reject registration via username/password.
     */
    Accounts.validateNewUser(function(attemptInfo) {
        if (attemptInfo && attemptInfo.services && attemptInfo.services.password) {
            return false;
        }

        return true;
    });
});

您的上一个错误来自于向帐户设置发送冲突消息。您可能想删除注册页面的 route configuration