Euphe Euphe - 7 months ago 11
HTML Question

How to create a log in system with meteor?

I am trying to get the grasp of meteor, but I am a certain beginner. Going to ask for help with a very basic thing here.

How do I create 2 forms (for login and password input) and a button that will register an account using

Accounts.createUser(options, [callback])


I need to understand the very basic thing of how to tie two forms to the function.

EDIT: I tried a thing. Acting totally blind though.

if (Meteor.isClient) {
Template.login.account = function () {
if (Meteor.user() == null) {
return
<form id="login">
<input type="email" id="email" />
<input type="text" id="logintext" />
<input type="password" id="password" />
</form>

};
};
Template.login.events({
'click input' : Sumbit();
})
}

function Sumbit(){
var login, password, email;
document.getElementById('email').value = email;
document.getElementById('logintext').value = login;
document.getElementById('password').value = password;
Accounts.createUser(login, email, password)
}

Answer

Meteor already provides you with a quite decent user-system: accounts-api

And for the login-form: Simply add the accounts-ui package (meteor add accounts-ui) and add the function to your template:

<template name="main">
    {{loginButtons}} <!--These are your login-buttons -->
</template>

For further information: here are the docs for the accounts-ui package.

Comments