簡體   English   中英

如何禁用流星帳戶用戶注冊?

[英]howto disable meteor accounts user registration?

我正在使用流星帳戶進行登錄和用戶注冊。

在此處輸入圖片說明

當用戶點擊底線(注冊)時:

在此處輸入圖片說明

他被重定向到創建帳戶頁面:

在此處輸入圖片說明

這些頁面后面的代碼是jade模板和javascript的混合體。

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

似乎在點擊注冊鏈接時內容被替換了,據我所知...

我想通過禁用注冊頁面上的最終注冊按鈕和/或禁用完整的注冊頁面來阻止用戶創建新帳戶。

我也願意接受其他解決方案以防止用戶注冊。

相關: 如何在Meteor中將forbidClientAccountCreation設置為false?

更新:我也嘗試過

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;
    });
});

您的最后一個錯誤來自向帳戶設置發送沖突的消息。 您可能要刪除注冊頁面的路由配置

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM