i am using meteor accounts for login and user registration.
When a user hits the bottom line (register):
He gets redirected to the create account page:
The code behind these pages is a mixture of jade templates and javascript.
template(name="userFormsLayout")
section.auth-layout
section.auth-dialog
+Template.dynamic(template=content)
It seems like the content is replaced when hitting the register link and this is as far as my knowledge goes...
I would like to prevent users from creating new accounts by either disabling the final register button on the registration page and / or disable the complete registration page.
I am also open for other solutions to prevent useers from registering.
RELATED: How can I set forbidClientAccountCreation to false in Meteor?
UPDATE: I also tried this
AccountsTemplates.configure({
forbidClientAccountCreation: true
but got:
Error: signUp route configured but forbidClientAccountCreation set to true!
Can anyone help me with this issue?
i don't have the whole answer, but i can give you a couple pieces to get you started.
first, you can tell AccountsTemplates (AT) to use your layout. you can put this anywhere that's loaded to both client and server, e.g. lib/atConfig:
AccountsTemplates.configureRoute('signIn', {
layoutTemplate: 'LoginLayout'
});
here's the layout template:
<template name="LoginLayout">
<main>
<div>
{{> Template.dynamic template=main}}
</div>
</main>
</template>
in the JS, you can hide the bits of the template you don't want the user to see. here, i'm hiding the password form and a separator. you can dig into the DOM to figure out which bits you want to hide:
Template.LoginLayout.onRendered(function() {
this.autorun(() => {
if (this.subscriptionsReady()) {
Tracker.afterFlush(() => {
$('.at-pwd-form').remove();
$('.at-sep').remove();
});
}
});
});
for the server, you can check for new user attempts and reject them if they're made w/ username and password. i think this should work, but you may have to play around with it:
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;
});
});