Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////
- // both/both.js //
- ///////////////////////////
- Tasks1 = new Mongo.Collection('tasks1');
- ///////////////////////////
- // client/client.js //
- ///////////////////////////
- Template.login.events({
- 'click #logMe': function() {
- var credentials = [$('#id').val(), $('#pin').val()];
- Meteor.call('logMeIn', credentials);
- }
- });
- Template.footer.events({
- 'click button': function () {
- if ( this.text === "SUBMIT" ) {
- var inputs = document.getElementsByTagName('input');
- for (var i = 0; i < inputs.length; i++) {
- var params = {};
- params[inputs[i].name] = inputs[i].value;
- Meteor.call('addTasks1', params);
- }
- }
- }
- });
- ///////////////////////////
- // server/server.js //
- ///////////////////////////
- Meteor.methods({
- logMeIn: function (credentials) {
- Accounts.createUser({username: credentials[0], password: credentials[1]});
- }
- });
- Meteor.publish('tasks1', function(){
- return Tasks1.find({userId: this.userId});
- });
- Meteor.methods({
- addTasks1: function (doc) {
- if (Meteor.userId()) {
- Tasks1.insert(doc);
- } else {
- throw new Meteor.Error("Not Authorized");
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement