How to use the meteor/meteor.Meteor.user function in meteor

To help you get started, we’ve selected a few meteor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 4minitz / 4minitz / imports / collections / minutes_private.js View on Github external
// Make sure the user is logged in before changing collections
        if (!Meteor.userId()) {
            throw new Meteor.Error('not-authorized');
        }

        // Ensure user is moderator before sending the agenda
        let userRoles = new UserRoles(Meteor.userId());
        let aMin = new Minutes(id);
        if (userRoles.isModeratorOf(aMin.parentMeetingSeriesID())) {
            if (!GlobalSettings.isEMailDeliveryEnabled()) {
                console.log('Skip sending mails because email delivery is not enabled. To enable email delivery set enableMailDelivery to true in your settings.json file');
                throw new Meteor.Error('Cannot send agenda', 'Email delivery is not enabled in your 4minitz installation.');
            }

            if (!Meteor.isClient) {
                let emails = Meteor.user().emails;
                let senderEmail = (emails && emails.length > 0)
                    ? emails[0].address
                    : GlobalSettings.getDefaultEmailSenderAddress();
                let sendAgendaMailHandler = new SendAgendaMailHandler(senderEmail, aMin);
                sendAgendaMailHandler.send();

                MinutesSchema.update({_id: aMin._id, isFinalized: false}, {$set: {agendaSentAt: new Date()}});

                return sendAgendaMailHandler.getCountRecipients();
            }
        } else {
            throw new Meteor.Error('Cannot send agenda', 'You are not moderator of the parent meeting series.');
        }
    },
github 4minitz / 4minitz / imports / collections / minutes_private.js View on Github external
'minutes.updateTopic'(topicId, doc) {
        check(topicId, String);
        console.log(`updateTopic: ${topicId}`);

        // Make sure the user is logged in before changing collections
        if (!Meteor.userId()) {
            throw new Meteor.Error('not-authorized', 'You are not authorized to perform this action.');
        }

        doc.updatedAt = new Date();
        doc.updatedBy = User.PROFILENAMEWITHFALLBACK(Meteor.user());

        let modifierDoc = {};
        for (let property in doc) {
            if (doc.hasOwnProperty(property)) {
                modifierDoc['topics.$.' + property] = doc[property];
            }
        }

        let minDoc = MinutesSchema.findOne({isFinalized: false, 'topics._id': topicId});
        let aMin = new Minutes(minDoc);

        // Ensure user can not update documents of other users
        let userRoles = new UserRoles(Meteor.userId());
        if (userRoles.isModeratorOf(aMin.parentMeetingSeriesID())) {
            // Ensure user can not update finalized minutes
github reactioncommerce / reaction / server / methods / accounts / accounts.js View on Github external
display: true,
        icon: `${Meteor.absoluteUrl()}resources/email-templates/facebook-icon.png`,
        link: "https://www.facebook.com"
      },
      googlePlus: {
        display: true,
        icon: `${Meteor.absoluteUrl()}resources/email-templates/google-plus-icon.png`,
        link: "https://plus.google.com"
      },
      twitter: {
        display: true,
        icon: `${Meteor.absoluteUrl()}resources/email-templates/twitter-icon.png`,
        link: "https://www.twitter.com"
      }
    },
    user: Meteor.user(), // Account Data
    currentUserName,
    invitedUserName: name,
    url: url || getEmailUrl(token)
  };

  function getEmailUrl(userToken) {
    if (userToken) {
      return MeteorAccounts.urls.enrollAccount(userToken);
    }
    return Meteor.absoluteUrl();
  }
}
github CommonBike / commonbike-site / app / imports / client / components / Login / Login.jsx View on Github external
export default createContainer((props) => {
  return {
    currentUser: Meteor.user(),
    // settings: Settings.findOne({})
  };
}, Login);
github catsass19 / Sapporo / imports / ui / login.jsx View on Github external
componentDidUpdate() {
        if (Meteor.user()) {
            console.log('go dashboard');
            goPage('dashboard');
        }
    }
    render () {
github ACGN-stock / acgn-stock / client / foundation / foundationList.js View on Github external
alreadyInvest() {
    const user = Meteor.user();
    if (user) {
      const userId = user._id;
      const invest = this.invest;
      const investData = _.findWhere(invest, { userId });
      if (investData) {
        return investData.amount;
      }
    }

    return 0;
  },
  cardDisplayClass() {
github ACGN-stock / acgn-stock / server / methods / accuse.js View on Github external
fscAnnouncement(userId, message) {
    check(this.userId, String);
    check(userId, [String]);
    check(message, String);
    fscAnnouncement(Meteor.user(), userId, message);

    return true;
  }
});
github thm-projects / arsnova-flashcards / imports / api / profile.js View on Github external
static isCompleted (user = undefined) {
		let birthname, givenname, email;
		if (user === undefined) {
			birthname = Meteor.user().profile.birthname !== "" && Meteor.user().profile.birthname !== undefined;
			givenname = Meteor.user().profile.givenname !== "" && Meteor.user().profile.givenname !== undefined;
			email = Meteor.user().email !== "" && Meteor.user().email !== undefined;
		} else {
			birthname = user.profile.birthname !== "" && user.profile.birthname !== undefined;
			givenname = user.profile.givenname !== "" && user.profile.givenname !== undefined;
			email = user.email !== "" && user.email !== undefined;
		}
		return (birthname && givenname && email);
	}
};
github thm-projects / arsnova-flashcards / imports / ui / useCases / item / myTranscripts.js View on Github external
gotCardIndex: function () {
		if (Meteor.user() && Meteor.user().count !== undefined) {
			return Meteor.user().count.transcripts > 0;
		}
	}
});
github ACGN-stock / acgn-stock / server / methods / accuse.js View on Github external
takeDownAdvertising(advertisingId) {
    check(this.userId, String);
    check(advertisingId, String);
    takeDownAdvertising(Meteor.user(), advertisingId);

    return true;
  }
});