Ejemplo n.º 1
0
  expressCheckoutAccountOptions: function () {
    const prefix = getSlug(ReactionCore.getShopName().toLowerCase());
    const shopId = ReactionCore.getShopId();
    let settings = Packages.findOne({
      name: "reaction-paypal",
      shopId: shopId,
      enabled: true
    }).settings;
    let mode;
    if ((settings !== null ? settings.express_mode : void 0) === true) {
      mode = "production";
    } else {
      mode = "sandbox";
    }
    let ref = Meteor.settings.paypal;

    let options = {
      enabled: settings !== null ? settings.express_enabled : void 0,
      mode: mode,
      username: getSettings(settings, ref, "username"),
      password: getSettings(settings, ref, "password"),
      signature: getSettings(settings, ref, "signature"),
      merchantId: getSettings(settings, ref, "merchantId"),
      return_url: Meteor.absoluteUrl(`${prefix}/paypal/done`),
      cancel_url: Meteor.absoluteUrl(`${prefix}/paypal/cancel`)
    };
    if (options.mode === "sandbox") {
      options.url = "https://api-3t.sandbox.paypal.com/nvp";
    } else {
      options.url = "https://api-3t.paypal.com/nvp";
    }
    return options;
  },
Ejemplo n.º 2
0
function _getLink(attachment) {
	const url = attachment.title_link.replace(/ /g, '%20');

	if (url.match(/^(https?:)?\/\//i)) {
		return url;
	} else {
		return Meteor.absoluteUrl().replace(/\/$/, '') + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + url;
	}
}
Ejemplo n.º 3
0
    Meteor.call('url.create', url, function(err, result){
      if(!result){
        // shorten failed
        Session.set("shortURL", "Could not shorten this URL, pls double check.");
        return;
      }

      console.log(err, result);
      Session.set("shortURL", Meteor.absoluteUrl(result));
    });
Ejemplo n.º 4
0
        it('does not allow more than 5 operations rapidly', () => {
          const connection = DDP.connect(Meteor.absoluteUrl());

          _.times(5, () => {
            connection.call(insert.name, {});
          });

          assert.throws(() => {
            connection.call(insert.name, {});
          }, Meteor.Error, /too-many-requests/);

          connection.disconnect();
        });
Ejemplo n.º 5
0
	zlib.deflateRaw(request, function(err, buffer) {
		if (err) {
			return callback(err);
		}

		const base64 = buffer.toString('base64');
		let target = self.options.entryPoint;

		if (operation === 'logout') {
			if (self.options.idpSLORedirectURL) {
				target = self.options.idpSLORedirectURL;
			}
		}

		if (target.indexOf('?') > 0) {
			target += '&';
		} else {
			target += '?';
		}

		// TBD. We should really include a proper RelayState here
		let relayState;
		if (operation === 'logout') {
			// in case of logout we want to be redirected back to the Meteor app.
			relayState = Meteor.absoluteUrl();
		} else {
			relayState = self.options.provider;
		}

		const samlRequest = {
			SAMLRequest: base64,
			RelayState: relayState,
		};

		if (self.options.privateCert) {
			samlRequest.SigAlg = 'http://www.w3.org/2000/09/xmldsig#rsa-sha1';
			samlRequest.Signature = self.signRequest(querystring.stringify(samlRequest));
		}

		target += querystring.stringify(samlRequest);

		debugLog(`requestToUrl: ${ target }`);

		if (operation === 'logout') {
			// in case of logout we want to be redirected back to the Meteor app.
			return callback(null, target);

		} else {
			callback(null, target);
		}
	});
Ejemplo n.º 6
0
const sendAccountApprovedEmail = function(user) {
  let template = `Your user account has been approved by an administrator and you can now start using your account!
${Meteor.absoluteUrl()}

   Thanks!
  IOOS Registry`;

  Email.send({
    from: "ioos.us Administrator <*****@*****.**>",
    to: user.profile.email,
    subject: "IOOS Registry - Welcome Aboard!",
    text: template
  });
};
 render () {
   const { documentAccess } = this.props
   return <div className='document-link-sharing'>
     <ul>
       <li>
         Can edit (users have to login or register)&nbsp;
         {documentAccess && documentAccess.linkCanEdit ? <div>
           <input ref='editLink' type='text' value={Meteor.absoluteUrl() + 'document/' + this.props.documentId + '?action=shared&permission=edit&accessKey=' + documentAccess.linkCanEdit.linkId} />
           <button className='btn btn-link' onClick={() => this.copyToClipboard('edit')}>Copy to clipboard</button>
           <button className='btn btn-danger' onClick={() => this.removeSharingLink('CanEdit')}>Remove Edit Sharing Link</button>
         </div> : <button className='btn btn-default gen-can-edit-link-btn' onClick={() => this.generateSharingLink('CanEdit')}>
           Generate Edit Link
         </button>}
       </li>
       <li>
         Can comment (users have to login or register)&nbsp;
         {documentAccess && documentAccess.linkCanComment ? <div>
           <input ref='commentLink' type='text' value={Meteor.absoluteUrl() + 'document/' + this.props.documentId + '?action=shared&permission=comment&accessKey=' + documentAccess.linkCanComment.linkId} />
           <button className='btn btn-link' onClick={() => this.copyToClipboard('comment')}>Copy to clipboard</button>
           <button className='btn btn-danger' onClick={() => this.removeSharingLink('CanComment')}>Remove Comment Sharing Link</button>
         </div> : <button className='btn btn-default gen-can-comment-link-btn' onClick={() => this.generateSharingLink('CanComment')}>
           Generate Commenting Link
         </button>}
       </li>
       <li>
         Can view&nbsp;
         {documentAccess && documentAccess.linkCanView ? <div>
           <input ref='viewLink' type='text' value={Meteor.absoluteUrl() + 'document/' + this.props.documentId + '?action=shared&permission=view&accessKey=' + documentAccess.linkCanView.linkId} />
           <button className='btn btn-link' onClick={() => this.copyToClipboard('view')}>Copy to clipboard</button>
           <button className='btn btn-danger' onClick={() => this.removeSharingLink('CanView')}>Remove View Sharing Link</button>
         </div> : <button className='btn btn-default gen-can-view-link-btn' onClick={() => this.generateSharingLink('CanView')}>
           Generate View Link
         </button>}
       </li>
     </ul>
   </div>
 }
Ejemplo n.º 8
0
			fileStore.insert(details, stream, (err, file) => {
				if (err) {
					throw new Error(err);
				} else {
					const url = file.url.replace(Meteor.absoluteUrl(), '/');
					const attachment = {
						title: file.name,
						title_link: url,
					};

					if (/^image\/.+/.test(file.type)) {
						attachment.image_url = url;
						attachment.image_type = file.type;
						attachment.image_size = file.size;
						attachment.image_dimensions = file.identify && file.identify.size;
					}
					if (/^audio\/.+/.test(file.type)) {
						attachment.audio_url = url;
						attachment.audio_type = file.type;
						attachment.audio_size = file.size;
					}
					if (/^video\/.+/.test(file.type)) {
						attachment.video_url = url;
						attachment.video_type = file.type;
						attachment.video_size = file.size;
					}

					const msg = {
						rid: details.rid,
						ts: timeStamp,
						msg: '',
						file: {
							_id: file._id,
						},
						groupable: false,
						attachments: [attachment],
					};

					if (isImporting) {
						msg.imported = 'slackbridge';
					}

					if (details.message_id && (typeof details.message_id === 'string')) {
						msg._id = details.message_id;
					}

					return RocketChat.sendMessage(rocketUser, msg, rocketChannel, true);
				}
			});
Ejemplo n.º 9
0
export function invite(partyId, userId) {
    check(partyId, String);
    check(userId, String);

    if(!this.userId) {
        throw new Meteor.Error(400, 'You have to be logged in!');
    }

    const party = Parties.findOne(partyId);

    if (!party) {
        throw new Meteor.Error(404, 'No such party exists');
    }

    if (party.owner !== this.userId) {
        throw new Meteor.Error(404, 'No permissions!');
    }

    if (party.public) {
        throw new Meteor.Error(400, 'That party is public. No need to invite people');
    }

    if (userId !== party.owner && ! _.contains(party.invited, userId)) {
        Parties.update(partyId, {
            $addToSet: {
                invited: userId
            }
        });

        const replyTo = getContactEmail(Meteor.users.findOne(this.userId));
        const to = getContactEmail(Meteor.users.findOne(userId));

        if (Meteor.isServer && to) {
            Email.send({
                to,
                replyTo,
                from: '*****@*****.**',
                subject: `Party: ${party.name}`,
                text: `
                    Hey, I just invited you to ${party.name} on Socially.

                    '${party.description}'

                    Come check it out: ${Meteor.absoluteUrl()}
                    `
            });
        }
    }
}
Ejemplo n.º 10
0
files.getFullFileUrl = pathInStore => {
    confUF = confUF || UniConfig.public.get('universe:files');
    const {UPLOADS_URL} = confUF || {};
    if (/\/$/.test(UPLOADS_URL)) {
        return UPLOADS_URL + pathInStore;
    }
    let url = UPLOADS_URL + '/' + pathInStore;
    if (httpRegx.test(url)) {
        return url;
    }
    if (url[0] === '/'){
        url = url.substr(1);
    }
    return Meteor.absoluteUrl(url);
};
Ejemplo n.º 11
0
	$(document.body).on('click', function(e) {
		if (e.target.tagName === 'A') {
			const link = e.currentTarget;
			if (link.origin === s.rtrim(Meteor.absoluteUrl(), '/') && /msg=([a-zA-Z0-9]+)/.test(link.search)) {
				e.preventDefault();
				e.stopPropagation();
				if (Layout.isEmbedded()) {
					return fireGlobalEvent('click-message-link', {
						link: link.pathname + link.search,
					});
				}
				return FlowRouter.go(link.pathname + link.search, null, FlowRouter.current().queryParams);
			}
		}
	});
Ejemplo n.º 12
0
  "orders/sendNotification": function (order) {
    check(order, Object);

    // just make sure this a real userId
    // todo: ddp limit
    if (!Meteor.userId()) {
      throw new Meteor.Error(403, "Access Denied");
    }

    this.unblock();
    if (order) {
      let shop = Shops.findOne(order.shopId);
      let shipment = order.shipping[0];

      Reaction.configureMailUrl();
      Logger.info("orders/sendNotification", order.workflow.status);
      // handle missing root shop email
      if (!shop.emails[0].address) {
        shop.emails[0].address = "*****@*****.**";
        Logger.warn("No shop email configured. Using no-reply to send mail");
      }
      // anonymous users without emails.
      if (!order.email) {
        Logger.warn("No shop email configured. Using anonymous order.");
        return true;
      }
      // email templates can be customized in Templates collection
      // loads defaults from reaction-email-templates/templates
      let tpl = `orders/${order.workflow.status}`;
      SSR.compileTemplate(tpl, ReactionEmailTemplate(tpl));
      try {
        return Email.send({
          to: order.email,
          from: `${shop.name} <${shop.emails[0].address}>`,
          subject: `Order update from ${shop.name}`,
          html: SSR.render(tpl, {
            homepage: Meteor.absoluteUrl(),
            shop: shop,
            order: order,
            shipment: shipment
          })
        });
      } catch (error) {
        Logger.fatal("Unable to send notification email: " + error);
        throw new Meteor.Error("error-sending-email", "Unable to send order notification email.", error);
      }
    }
  },
Ejemplo n.º 13
0
export const GiveawaySharingCard = ({ ga }) => (
  <PaperCard className="giveaway">
    <div className="flex-row">
      <div className="col col-xs-12">
        <h3>Share</h3>
        <TextField
          id="share-url"
          fullWidth={true}
          inputStyle={{ fontSize: "12px" }}
          value={ Meteor.absoluteUrl('giveaway/' + ga._id) }
          onTouchTap={ () => $("#share-url").select() } />
        <ShareItWrapper ga={ga} />
      </div>
    </div>
  </PaperCard>
);
Ejemplo n.º 14
0
		oauthProviders: async() => {
			// depends on rocketchat:grant package
			try {
				const result = HTTP.get(Meteor.absoluteUrl('_oauth_apps/providers')).content;

				if (isJSON(result)) {
					const providers = JSON.parse(result).data;

					return providers.map((name) => ({ name }));
				} else {
					throw new Error('Could not parse the result');
				}
			} catch (e) {
				throw new Error('rocketchat:grant not installed');
			}
		},
Ejemplo n.º 15
0
export function invite(partyId, userId) {
  check(partyId, String);
  check(userId, String);

  if (!this.userId) {
    throw new Meteor.Error(400, 'You have to be logged in!');
  }

  const party = Festas.findOne(partyId);

  if (!party) {
    throw new Meteor.Error(404, 'No such party!');
  }

  if (party.owner !== this.userId) {
    throw new Meteor.Error(404, 'No permissions!');
  }

  if (party.public) {
    throw new Meteor.Error(400, 'That party is public. No need to invite people.');
  }

  if (userId !== party.owner && ! _.contains(party.invited, userId)) {
    Festas.update(partyId, {
      $addToSet: {
        invited: userId
      }
    });

    const replyTo = getContactEmail(Meteor.users.findOne(this.userId));
    const to = getContactEmail(Meteor.users.findOne(userId));

    if (Meteor.isServer && to) {
      Email.send({
        to,
        replyTo,
        from: '*****@*****.**',
        subject: `PARTY: ${party.title}`,
        text: `
          Olá, Eu gostaria de convidar você para a ${party.title} do grupo.
          Confira o convite no link: ${Meteor.absoluteUrl()}
        `
      });
    }
  }
}
Ejemplo n.º 16
0
export function invite(eventId, userId) {
  check(eventId, String);
  check(userId, String);

  if (!this.userId) {
    throw new Meteor.Error(400, 'You have to be logged in!');
  }

  const event = Events.findOne(eventId);

  if (!event) {
    throw new Meteor.Error(404, 'No such event!');
  }

  if (event.owner !== this.userId) {
    throw new Meteor.Error(404, 'No permissions!');
  }

  if (event.public) {
    throw new Meteor.Error(400, 'That event is public. No need to invite people.');
  }

  if (userId !== event.owner && ! _.contains(event.invited, userId)) {
    Events.update(eventId, {
      $addToSet: {
        invited: userId
      }
    });

    const replyTo = getContactEmail(Meteor.users.findOne(this.userId));
    const to = getContactEmail(Meteor.users.findOne(userId));

    if (Meteor.isServer && to) {
      Email.send({
        to,
        replyTo,
        from: '*****@*****.**',
        subject: `PARTY: ${event.title}`,
        text: `
          Hey, I just invited you to ${event.title} on Heroes.
          Come check it out: ${Meteor.absoluteUrl()}
        `
      });
    }
  }
}
Ejemplo n.º 17
0
export function getShopName() {
  const shopId = getShopId();
  let shop;
  if (shopId) {
    shop = Shops.findOne({
      _id: shopId
    });
    return shop && shop.name || "";
  }

  const domain = url.parse(Meteor.absoluteUrl()).hostname;

  shop = Shops.find({ domains: { $in: [domain] } }, {
    limit: 1
  }).fetch()[0];

  return !!shop ? shop.name : "";
}
Ejemplo n.º 18
0
const casTicket = function(req, token, callback) {

	// get configuration
	if (!settings.get('CAS_enabled')) {
		logger.error('Got ticket validation request, but CAS is not enabled');
		callback();
	}

	// get ticket and validate.
	const parsedUrl = url.parse(req.url, true);
	const ticketId = parsedUrl.query.ticket;
	const baseUrl = settings.get('CAS_base_url');
	const cas_version = parseFloat(settings.get('CAS_version'));
	const appUrl = Meteor.absoluteUrl().replace(/\/$/, '') + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;
	logger.debug(`Using CAS_base_url: ${ baseUrl }`);

	const cas = new CAS({
		base_url: baseUrl,
		version: cas_version,
		service: `${ appUrl }/_cas/${ token }`,
	});

	cas.validate(ticketId, Meteor.bindEnvironment(function(err, status, username, details) {
		if (err) {
			logger.error(`error when trying to validate: ${ err.message }`);
		} else if (status) {
			logger.info(`Validated user: ${ username }`);
			const user_info = { username };

			// CAS 2.0 attributes handling
			if (details && details.attributes) {
				_.extend(user_info, { attributes: details.attributes });
			}
			CredentialTokens.create(token, user_info);
		} else {
			logger.error(`Unable to validate ticket: ${ ticketId }`);
		}
		// logger.debug("Receveied response: " + JSON.stringify(details, null , 4));

		callback();
	}));

	return;
};
Ejemplo n.º 19
0
	return Meteor.users.find(userQuery).forEach(function(user) {
		const email = `${ user.name } <${ user.emails[0].address }>`;

		const html = placeholders.replace(body, {
			unsubscribe: Meteor.absoluteUrl(FlowRouter.path('mailer/unsubscribe/:_id/:createdAt', {
				_id: user._id,
				createdAt: user.createdAt.getTime(),
			})),
			name: s.escapeHTML(user.name),
			email: s.escapeHTML(email),
		});
		console.log(`Sending email to ${ email }`);
		return Mailer.send({
			to: email,
			from,
			subject,
			html,
		});
	});
  before(function () {
    clientTestColl = new JobCollection("ClientTest", { idGeneration: "MONGO" });
    serverTestColl = new JobCollection("ServerTest", { idGeneration: "STRING" });

    if (Meteor.isServer) {
      const remoteTestColl = new JobCollection("RemoteTest", { idGeneration: "STRING" });
      remoteTestColl.allow({ admin() { return true; } });
    } else {
      const remoteConnection = DDP.connect(Meteor.absoluteUrl());
      remoteServerTestColl = new JobCollection("RemoteTest", { idGeneration: "STRING", connection: remoteConnection });
    }

    // This is defined differently for client / server
    testColl = Meteor.isClient ? clientTestColl : serverTestColl;

    if (Meteor.isServer) {
      clientTestColl.allow({ admin() { return true; } });
    }
  });
Ejemplo n.º 21
0
    return Tracker.autorun(() => {
      let domain;
      let shop;

      if (this.Subscriptions.Shops.ready()) {
        domain = Meteor.absoluteUrl().split("/")[2].split(":")[0];
        shop = Shops.findOne({
          domains: domain
        });

        if (shop) {
          this.shopId = shop._id;
          this.shopName = shop.name;
          // initialize local client Countries collection
          if (!Countries.findOne()) {
            createCountryCollection(shop.locales.countries);
          }

          const locale = this.Locale.get() || {};

          // fix for https://github.com/reactioncommerce/reaction/issues/248
          // we need to keep an eye for rates changes
          if (typeof locale.locale === "object" &&
            typeof locale.currency === "object" &&
            typeof locale.locale.currency === "string") {
            const localeCurrency = locale.locale.currency.split(",")[0];
            if (typeof shop.currencies[localeCurrency] === "object") {
              if (typeof shop.currencies[localeCurrency].rate === "number") {
                locale.currency.rate = shop.currencies[localeCurrency].rate;
                localeDep.changed();
              }
            }
          }
          // we are looking for a shopCurrency changes here
          if (typeof locale.shopCurrency === "object") {
            locale.shopCurrency = shop.currencies[shop.currency];
            localeDep.changed();
          }
          return this;
        }
      }
    });
Ejemplo n.º 22
0
const sendNotificationEmail = function(user) {
  // find the emails of any admin users
  let base_admin_users = Meteor.users.aggregate([{$match: {roles: 'admin'}},
                                                 {'$group':
                                                     {_id: null, admin_emails:
                                                         { $addToSet:
                                                          "$profile.email"}}}])[0].admin_emails;

  // get the email notification list
  let notification_list;
  if(_.isEmpty(Meteor.settings.email) || _.isEmpty(Meteor.settings.email.notification_list)) {
    console.error("Notification list is not configured");
    //return;
    notification_list = [];
  } else {
    notification_list = Meteor.settings.email.notification_list;
  }
  // combine the addresses of the two, ignoring any duplicates
  const admin_and_notification_list = new Set([...base_admin_users,
                                               ...notification_list]);

  let template = `A new user has registered for an account

Email: ${user.email}
Name: ${user.name}
Organization(s): ${user.organization.join(", ")}
POC Name: ${user.poc_name}
POC Email: ${user.poc_email}

You can approve the account by logging in and visiting
    ${Meteor.absoluteUrl("users")}

   Thanks!
  IOOS Registry`;

  Email.send({
    from: "ioos.us Administrator <*****@*****.**>",
    to: Array.from(admin_and_notification_list),
    subject: "IOOS Registry New Registered User",
    text: template
  });
};
Ejemplo n.º 23
0
  sendOwnershipInvite(newOwnerId, transferId) {
    const orgName = this._organization.name;

    const subject = `You have been invited to become an owner of the ${orgName} organization`;
    const secondaryText = `If you agree to be an organization owner, click on "Confirm" button`;

    const url = Meteor.absoluteUrl(`transfer-organization/${transferId}`);

    const options = {
      organizationName: orgName,
      title: subject,
      secondaryText,
      button: {
        label: 'Confirm',
        url
      }
    };

    new NotificationSender(subject, 'minimalisticEmail', options).sendEmail(newOwnerId);
  }
Ejemplo n.º 24
0
WebApp.httpServer.addListener('request', function(req, res, ...args) {
	const next = () => {
		for (const oldListener of oldHttpServerListeners) {
			oldListener.apply(WebApp.httpServer, [req, res, ...args]);
		}
	};

	if (RocketChat.settings.get('Force_SSL') !== true) {
		next();
		return;
	}

	const remoteAddress = req.connection.remoteAddress || req.socket.remoteAddress;
	const localhostRegexp = /^\s*(127\.0\.0\.1|::1)\s*$/;
	const localhostTest = function(x) {
		return localhostRegexp.test(x);
	};

	const isLocal = localhostRegexp.test(remoteAddress) && (!req.headers['x-forwarded-for'] || _.all(req.headers['x-forwarded-for'].split(','), localhostTest));
	const isSsl = req.connection.pair || (req.headers['x-forwarded-proto'] && req.headers['x-forwarded-proto'].indexOf('https') !== -1);

	if (RocketChat && RocketChat.debugLevel === 'debug') {
		console.log('req.url', req.url);
		console.log('remoteAddress', remoteAddress);
		console.log('isLocal', isLocal);
		console.log('isSsl', isSsl);
		console.log('req.headers', req.headers);
	}

	if (!isLocal && !isSsl) {
		let host = req.headers.host || url.parse(Meteor.absoluteUrl()).hostname;
		host = host.replace(/:\d+$/, '');
		res.writeHead(302, {
			Location: `https://${ host }${ req.url }`,
		});
		res.end();
		return;
	}

	return next();
});
Ejemplo n.º 25
0
	Push.addListener('startup', function(notification) {
		// Meteor.call 'log', 'CLIENT', 'startup', arguments

		if (notification.payload && notification.payload.rid) {
			if (notification.payload.host === Meteor.absoluteUrl()) {
				switch (notification.payload.type) {
					case 'c':
						return FlowRouter.go('channel', { name: notification.payload.name }, FlowRouter.current().queryParams);
					case 'p':
						return FlowRouter.go('group', { name: notification.payload.name }, FlowRouter.current().queryParams);
					case 'd':
						return FlowRouter.go('direct', { username: notification.payload.sender.username }, FlowRouter.current().queryParams);
				}
			} else {
				let path = '';
				switch (notification.payload.type) {
					case 'c':
						path = `channel/${ notification.payload.name }`;
						break;
					case 'p':
						path = `group/${ notification.payload.name }`;
						break;
					case 'd':
						path = `direct/${ notification.payload.sender.username }`;
						break;
				}

				const host = notification.payload.host.replace(/\/$/, '');
				if (Servers.serverExists(host) !== true) {
					return;
				}

				return Servers.startServer(host, path, function(err) {
					if (err) {
						// TODO err
						return console.log(err);
					}
				});
			}
		}
	});
Ejemplo n.º 26
0
export function setCompanyMeta(company) {
  let companyName = company.name;
  let title = `${companyName} for Remote Jobs | RemoteBase`;
  let logoUrl = Meteor.absoluteUrl(company.logo_url.replace(/^\//, ''));
  let description = getDescription(company);
  let twitterDescription = getTwitterDescription(company);

  // reset any dynamically set tags in <head> previously
  DocHead.removeDocHeadAddedTags();
  DocHead.setTitle(title);
  DocHead.addMeta({name: 'description', content: description});
  DocHead.addMeta({name: 'twitter:card', content: 'summary'});
  DocHead.addMeta({name: 'twitter:site', content: '@remotebase'});
  DocHead.addMeta({name: 'twitter:title', content: title});
  DocHead.addMeta({name: 'twitter:image', content: logoUrl});
  DocHead.addMeta({name: 'twitter:description', content: twitterDescription});
  DocHead.addMeta({property: 'og:title', content: title});
  DocHead.addMeta({property: 'og:site_name', content: 'RemoteBase'});
  DocHead.addMeta({property: 'og:image', content: logoUrl});
  DocHead.addMeta({property: 'og:description', content: description});
}
Ejemplo n.º 27
0
export default (options, user) => {
  const OAuthProfile = getOAuthProfile(options, user);

  const applicationName = 'Application Name';
  const firstName = OAuthProfile ? OAuthProfile.name.first : options.profile.name.first;
  const emailAddress = OAuthProfile ? OAuthProfile.email : options.email;

  return sendEmail({
    to: emailAddress,
    from: `${applicationName} <*****@*****.**>`,
    subject: `[${applicationName}] Welcome, ${firstName}!`,
    template: 'welcome',
    templateVars: {
      applicationName,
      firstName,
      welcomeUrl: Meteor.absoluteUrl('documents'), // e.g., returns http://localhost:3000/documents
    },
  })
    .catch((error) => {
      throw new Meteor.Error('500', `${error}`);
    });
};
Ejemplo n.º 28
0
	postMessage(slackChannel, rocketMessage) {
		if (slackChannel && slackChannel.id) {
			let iconUrl = getAvatarUrlFromUsername(rocketMessage.u && rocketMessage.u.username);
			if (iconUrl) {
				iconUrl = Meteor.absoluteUrl().replace(/\/$/, '') + iconUrl;
			}
			const data = {
				token: this.apiToken,
				text: rocketMessage.msg,
				channel: slackChannel.id,
				username: rocketMessage.u && rocketMessage.u.username,
				icon_url: iconUrl,
				link_names: 1,
			};
			logger.slack.debug('Post Message To Slack', data);
			const postResult = HTTP.post('https://slack.com/api/chat.postMessage', { params: data });
			if (postResult.statusCode === 200 && postResult.data && postResult.data.message && postResult.data.message.bot_id && postResult.data.message.ts) {
				RocketChat.models.Messages.setSlackBotIdAndSlackTs(rocketMessage._id, postResult.data.message.bot_id, postResult.data.message.ts);
				logger.slack.debug(`RocketMsgID=${ rocketMessage._id } SlackMsgID=${ postResult.data.message.ts } SlackBotID=${ postResult.data.message.bot_id }`);
			}
		}
	}
Ejemplo n.º 29
0
	processFileShare(rocketMessage) {
		if (! RocketChat.settings.get('SlackBridge_FileUpload_Enabled')) {
			return;
		}

		if (rocketMessage.file.name) {
			let file_name = rocketMessage.file.name;
			let text = rocketMessage.msg;

			const attachment = this.getMessageAttachment(rocketMessage);
			if (attachment) {
				file_name = Meteor.absoluteUrl(attachment.title_link);
				if (!text) {
					text = attachment.description;
				}
			}

			const message = `${ text } ${ file_name }`;

			rocketMessage.msg = message;
			this.slack.postMessage(this.slack.getSlackChannel(rocketMessage.rid), rocketMessage);
		}
	}
Ejemplo n.º 30
0
				_saml.validateResponse(req.body.SAMLResponse, req.body.RelayState, function(err, profile/* , loggedOut*/) {
					if (err) {
						throw new Error(`Unable to validate response url: ${ err }`);
					}

					const credentialToken = (profile.inResponseToId && profile.inResponseToId.value) || profile.inResponseToId || profile.InResponseTo || samlObject.credentialToken;
					const loginResult = {
						profile,
					};
					if (!credentialToken) {
						// No credentialToken in IdP-initiated SSO
						const saml_idp_credentialToken = Random.id();
						Accounts.saml.storeCredential(saml_idp_credentialToken, loginResult);

						const url = `${ Meteor.absoluteUrl('home') }?saml_idp_credentialToken=${ saml_idp_credentialToken }`;
						res.writeHead(302, {
							Location: url,
						});
						res.end();
					} else {
						Accounts.saml.storeCredential(credentialToken, loginResult);
						closePopup(res);
					}
				});