I’m new Meteor.js and have been through the docs several times, I’m sure I’m missing something small here so I’m hoping someone can point me in the right direction.
I need to create a new input field inside main.html registration form, have main.js capture this to the database and then show after login.
I have the account-passwords package installed to note.
MAIN.HTML
<body>
{{#if currentUser}}
{{> dashboard}}
{{else}}
{{> register}}
{{> login}}
{{/if}}
</body>
<template name="dashboard">
<p>You're logged in.</p>
<p><a href="#" class="logout">Logout</a></p>
</template>
<template name="register" >
<div id="register">
<h1>Register</h1>
<form>
<input type="email" name="registerEmail">
<input type="password" name="registerPassword">
<input type="submit" value="Register">
</form>
</div>
</template>
<template name="login" >
<div id="login">
<h1>Login</h1>
<form>
<input type="email" name="loginEmail">
<input type="password" name="loginPassword">
<input type="submit" value="Login">
</form>
</div>
</template>
MAIN.JS
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import './main.html';
if (Meteor.isClient) {
Template.dashboard.events({
'click .logout': function(event){
event.preventDefault();
Meteor.logout();
}
});
Template.register.events({
'submit form': function(event){
event.preventDefault();
var emailVar = event.target.registerEmail.value;
var passwordVar = event.target.registerPassword.value;
Accounts.createUser({
email: emailVar,
password: passwordVar
});
}
});
Template.login.events({
'submit form': function(event){
event.preventDefault();
var emailVar = event.target.loginEmail.value;
var passwordVar = event.target.loginPassword.value;
Meteor.loginWithPassword(emailVar, passwordVar);
}
});
}
Thanks in advance!