Skip to content

Commit

Permalink
prevents delegation contract against myself
Browse files Browse the repository at this point in the history
  • Loading branch information
santisiri committed May 24, 2018
1 parent 798fc5f commit 4de9cbd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 1 addition & 10 deletions imports/ui/modules/Vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Session } from 'meteor/session';
import { TAPi18n } from 'meteor/tap:i18n';
import { $ } from 'meteor/jquery';

import { getDelegationContract, createDelegation } from '/imports/startup/both/modules/Contract';
import { getDelegationContract } from '/imports/startup/both/modules/Contract';
import { Contracts } from '/imports/api/contracts/Contracts';
import { convertToSlug } from '/lib/utils';
import { defaultSettings } from '/lib/const';
Expand Down Expand Up @@ -370,15 +370,6 @@ export class Vote {
settings.title = this.delegationContract.title;
settings.signatures = this.delegationContract.signatures;
settings.contractId = this.delegationContract._id;
} else {
// no delegation
/* delegateProfileId = this.targetId;
settings.title = `${convertToSlug(Meteor.users.findOne({ _id: this.userId }).username)}-${convertToSlug(Meteor.users.findOne({ _id: this.targetId }).username)}`;
settings.signatures = [{ username: Meteor.users.findOne({ _id: this.userId }).username }, { username: Meteor.users.findOne({ _id: this.targetId }).username }];
this.delegationContract = createDelegation(this.userId, this.targetId, settings);
settings.contractId = this.delegationContract._id;
*/
console.log('trying to create delegation at execution...');
}

switch (this.arrow) {
Expand Down
2 changes: 1 addition & 1 deletion lib/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ _views.delegationContracts = () => {
* @return {object} query to use on collection
*/
_views.bothDelegationContracts = (terms) => {
if (Meteor.user()) {
if (Meteor.user() && (Meteor.userId() !== terms.delegateId)) {
const query = { $and: [{ signatures: { $elemMatch: { _id: Meteor.userId() } } }, { signatures: { $elemMatch: { _id: terms.delegateId } } }, { kind: 'DELEGATION' }] };
const delegations = Contracts.find(query).fetch();
const delegateName = Meteor.users.findOne({ _id: terms.delegateId }).username;
Expand Down

0 comments on commit 4de9cbd

Please sign in to comment.