Skip to content

Commit

Permalink
Merge branch 'admin-refactor' of github.com:RocketChat/Rocket.Chat in…
Browse files Browse the repository at this point in the history
…to new/oauth_page

* 'admin-refactor' of github.com:RocketChat/Rocket.Chat:
  [FIX] Directory search user placeholder (#17652)
  [NEW] Added "Add custom emoji" link to emoji picker (#16250)
  [FIX] Marketplace tiered pricing plan wording (#17644)
  [FIX] Secret Registration not properly validating Invite Token (#17618)
  Improve: New PR Template (#16968)
  Add engine versions for houston with templates (#17403)
  Use Users.findOneByAppId instead of querying directly (#16480)
  Remove unnecessary setting redefinition (#17587)
  Deprecate compatibility cordova setting (#17586)
  • Loading branch information
ggazzo committed May 15, 2020
2 parents f03f3e2 + ae745bb commit 1649daa
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 44 deletions.
45 changes: 40 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -1,11 +1,46 @@
<!-- INSTRUCTION: Your Pull Request name should start with one of the following tags -->
<!-- This is a pull request template, you do not need to uncomment or remove the comments, they won't show up in the PR text. -->
<!-- Your Pull Request name should start with one of the following tags -->
<!-- [NEW] For new features -->
<!-- [FIX] For bug fixes -->
<!-- [BREAK] For pull requests including breaking changes -->

<!-- INSTRUCTION: Inform the issue number that this PR closes, or remove the line below -->
Closes #ISSUE_NUMBER
## Proposed changes
<!-- Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue below. -->

<!-- INSTRUCTION: Link to a https://github.com/RocketChat/docs PR with added/updated documentation or an update to the missing/outdated documentation list, see https://rocket.chat/docs/contributing/documentation/ -->
## Issue(s)
<!-- Link the issues being closed by or related to this PR. For example, you can use #594 if this PR closes issue number 594 -->

## How to test or reproduce
<!-- Mention how you would reproduce the bug if not mentioned on the issue page already. Also mention which screens are going to have the changes if applicable -->

## Screenshots

## Types of changes
<!-- What types of changes does your code introduce to Rocket.Chat? -->
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] Improvement (non-breaking change which improves a current function)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Hotfix (a major bugfix that has to be merged asap)
- [ ] Documentation Update (if none of the other choices apply)

## Checklist
<!-- Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code. -->

- [ ] I have read the [CONTRIBUTING](https://github.com/RocketChat/Rocket.Chat/blob/develop/.github/CONTRIBUTING.md#contributing-to-rocketchat) doc
- [ ] I have signed the [CLA](https://cla-assistant.io/RocketChat/Rocket.Chat)
- [ ] Lint and unit tests pass locally with my changes
- [ ] I have added tests that prove my fix is effective or that my feature works (if applicable)
- [ ] I have added necessary documentation (if applicable)
- [ ] Any dependent changes have been merged and published in downstream modules

## Changelog
<!-- CHANGELOG -->
<!-- Enter HERE a brief text that would go up on the changelog on our releases page -->
<!-- END CHANGELOG -->

## Further comments
<!-- If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... -->

<!-- INSTRUCTION: Tell us more about your PR with screen shots if you can -->
File renamed without changes.
2 changes: 2 additions & 0 deletions .houston/templates/prs.hbs
@@ -0,0 +1,2 @@
{{> versions}}
{{> _prs}}
13 changes: 13 additions & 0 deletions .houston/templates/versions.hbs
@@ -0,0 +1,13 @@
{{#if (or release.node_version release.npm_version release.mongo_versions)}}

### Engine versions
{{#if release.node_version}}
- Node: `{{ release.node_version }}`
{{/if}}
{{#if release.npm_version}}
- NPM: `{{ release.npm_version }}`
{{/if}}
{{#if release.mongo_versions}}
- MongoDB: `{{ join release.mongo_versions ', ' }}`
{{/if}}
{{/if}}
3 changes: 2 additions & 1 deletion app/apps/client/admin/helpers.js
Expand Up @@ -363,11 +363,12 @@ export const appStatusSpanProps = ({

export const formatPrice = (price) => `\$${ Number.parseFloat(price).toFixed(2) }`;

export const formatPricingPlan = ({ strategy, price, tiers }) => {
export const formatPricingPlan = ({ strategy, price, tiers = [] }) => {
const { perUnit = false } = (Array.isArray(tiers) && tiers.find((tier) => tier.price === price)) || {};

const pricingPlanTranslationString = [
'Apps_Marketplace_pricingPlan',
Array.isArray(tiers) && tiers.length > 0 && 'startingAt',
strategy,
perUnit && 'perUser',
].filter(Boolean).join('_');
Expand Down
5 changes: 2 additions & 3 deletions app/apps/server/bridges/users.js
@@ -1,10 +1,9 @@
import { Random } from 'meteor/random';

import { setUserAvatar, checkUsernameAvailability, deleteUser, _setStatusTextPromise } from '../../../lib/server/functions';
import { Users } from '../../../models';
import { Users } from '../../../models/server';
import { Users as UsersRaw } from '../../../models/server/raw';


export class AppUserBridge {
constructor(orch) {
this.orch = orch;
Expand All @@ -25,7 +24,7 @@ export class AppUserBridge {
async getAppUser(appId) {
this.orch.debugLog(`The App ${ appId } is getting its assigned user`);

const user = Users.findOne({ appId });
const user = Users.findOneByAppId(appId);

return this.orch.getConverters().get('users').convertToApp(user);
}
Expand Down
27 changes: 14 additions & 13 deletions app/cors/server/cors.js
Expand Up @@ -44,6 +44,7 @@ WebApp.rawConnectHandlers.use(Meteor.bindEnvironment(function(req, res, next) {
});
}));

// Deprecated setting
let Support_Cordova_App = false;
settings.get('Support_Cordova_App', (key, value) => {
Support_Cordova_App = value;
Expand All @@ -53,24 +54,24 @@ WebApp.rawConnectHandlers.use(function(req, res, next) {
// XSS Protection for old browsers (IE)
res.setHeader('X-XSS-Protection', '1');

if (Support_Cordova_App !== true) {
return next();
}

if (/^\/(api|_timesync|sockjs|tap-i18n)(\/|$)/.test(req.url)) {
res.setHeader('Access-Control-Allow-Origin', '*');
}
if (settings.get('Iframe_Restrict_Access')) {
res.setHeader('X-Frame-Options', settings.get('Iframe_X_Frame_Options'));
}

const { setHeader } = res;
res.setHeader = function(key, val, ...args) {
if (key.toLowerCase() === 'access-control-allow-origin' && val === 'http://meteor.local') {
return;
// Deprecated behavior
if (Support_Cordova_App === true) {
if (/^\/(api|_timesync|sockjs|tap-i18n)(\/|$)/.test(req.url)) {
res.setHeader('Access-Control-Allow-Origin', '*');
}
return setHeader.apply(this, [key, val, ...args]);
};

const { setHeader } = res;
res.setHeader = function(key, val, ...args) {
if (key.toLowerCase() === 'access-control-allow-origin' && val === 'http://meteor.local') {
return;
}
return setHeader.apply(this, [key, val, ...args]);
};
}

return next();
});
Expand Down
5 changes: 4 additions & 1 deletion app/emoji/client/emojiPicker.html
Expand Up @@ -44,6 +44,9 @@ <h4 class="emoji-list-category" id="emoji-list-category-{{category.key}}">{{_ ca
{{/each}}
{{/if}}
</div>
<div class="emoji-footer">{{{_"Emoji_provided_by_JoyPixels"}}}</div>
<div class="emoji-footer">
{{#if hasPermission 'manage-emoji'}}<a class="add-custom" href="/admin/emoji-custom">{{_"Add_custom_emoji"}}</a>{{/if}}
{{{_"Emoji_provided_by_JoyPixels"}}}
</div>
</div>
</template>
7 changes: 7 additions & 0 deletions app/emoji/client/emojiPicker.js
@@ -1,6 +1,7 @@
import _ from 'underscore';
import { ReactiveVar } from 'meteor/reactive-var';
import { ReactiveDict } from 'meteor/reactive-dict';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';

import { t } from '../../utils/client';
Expand Down Expand Up @@ -142,6 +143,12 @@ Template.emojiPicker.events({
event.stopPropagation();
event.preventDefault();
},
'click .add-custom'(event) {
event.stopPropagation();
event.preventDefault();
FlowRouter.go('/admin/emoji-custom');
EmojiPicker.close();
},
'click .category-link'(event) {
event.stopPropagation();
event.preventDefault();
Expand Down
2 changes: 2 additions & 0 deletions app/lib/server/startup/settings.js
Expand Up @@ -874,6 +874,8 @@ settings.addGroup('General', function() {
type: 'boolean',
public: true,
});

// Deprecated setting
this.add('Support_Cordova_App', false, {
type: 'boolean',
i18nDescription: 'Support_Cordova_App_Description',
Expand Down
2 changes: 1 addition & 1 deletion app/mailer/server/api.js
Expand Up @@ -23,7 +23,7 @@ settings.get('Language', (key, value) => {
lng = value || 'en';
});

export const replacekey = (str, key, value = '') => str.replace(new RegExp(`(\\[${ key }\\]|__${ key }__)`, 'igm'), value);
export const replacekey = (str, key, value = '') => str.replace(new RegExp(`(\\[${ key }\\]|__${ key }__)`, 'igm'), s.escapeHTML(value));
export const translate = (str) => str.replace(/\{ ?([^\} ]+)(( ([^\}]+))+)? ?\}/gmi, (match, key) => TAPi18n.__(key, { lng }));
export const replace = function replace(str, data = {}) {
if (!str) {
Expand Down
6 changes: 6 additions & 0 deletions app/theme/client/imports/components/emojiPicker.css
Expand Up @@ -122,6 +122,12 @@
font-size: 12px;

font-weight: 500;

& .add-custom {
display: inline-block;

width: 100%;
}
}

.emoji-top {
Expand Down
2 changes: 1 addition & 1 deletion app/ui/client/views/app/components/Directory/UserTab.js
Expand Up @@ -23,7 +23,7 @@ const FilterByText = ({ setFilter, ...props }) => {
}, [text]);

return <Box mb='x16' is='form' display='flex' flexDirection='column' {...props}>
<TextInput flexShrink={0} placeholder={t('Search_Channels')} addon={<Icon name='magnifier' size='x20'/>} onChange={handleChange} value={text} />
<TextInput flexShrink={0} placeholder={t('Search_Users')} addon={<Icon name='magnifier' size='x20'/>} onChange={handleChange} value={text} />
</Box>;
};

Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -253,9 +253,10 @@
}
},
"houston": {
"metadata": ".scripts/houstonMetadata.js",
"minTag": "0.55.0-rc.0",
"updateFiles": [
"package.json",
"package-lock.json",
".circleci/snap.sh",
".circleci/update-releases.sh",
".docker/Dockerfile",
Expand Down
5 changes: 5 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Expand Up @@ -233,6 +233,7 @@
"MAU_value": "MAU __value__",
"Activity": "Activity",
"Add": "Add",
"Add_custom_emoji": "Add custom emoji",
"add-oauth-service": "Add Oauth Service",
"add-oauth-service_description": "Permission to add a new Oauth service",
"add-user": "Add User",
Expand Down Expand Up @@ -410,9 +411,13 @@
"Apps_Marketplace_Login_Required_Title": "Marketplace Login Required",
"Apps_Marketplace_Login_Required_Description": "Purchasing apps from the Rocket.Chat Marketplace requires registering your workspace and logging in.",
"Apps_Marketplace_pricingPlan_monthly": "__price__ / month",
"Apps_Marketplace_pricingPlan_startingAt_monthly": "starting at __price__ / month",
"Apps_Marketplace_pricingPlan_monthly_perUser": "__price__ / month per user",
"Apps_Marketplace_pricingPlan_startingAt_monthly_perUser": "starting at __price__ / month per user",
"Apps_Marketplace_pricingPlan_yearly": "__price__ / year",
"Apps_Marketplace_pricingPlan_startingAt_yearly": "starting at __price__ / year",
"Apps_Marketplace_pricingPlan_yearly_perUser": "__price__ / year per user",
"Apps_Marketplace_pricingPlan_startingAt_yearly_perUser": "starting at __price__ / year per user",
"Apps_Settings": "App's Settings",
"Apps_User_Already_Exists": "The username \"__username__\" is already being used. Rename or remove the user using it to install this App",
"Apps_WhatIsIt": "Apps: What Are They?",
Expand Down
26 changes: 8 additions & 18 deletions server/methods/registerUser.js
Expand Up @@ -3,18 +3,11 @@ import { Match, check } from 'meteor/check';
import { Accounts } from 'meteor/accounts-base';
import s from 'underscore.string';

import * as Mailer from '../../app/mailer';
import { Users } from '../../app/models';
import { settings } from '../../app/settings';
import { saveCustomFields, validateEmailDomain, passwordPolicy } from '../../app/lib';
import { validateInviteToken } from '../../app/invites/server/functions/validateInviteToken';

let verifyEmailTemplate = '';
Meteor.startup(() => {
Mailer.getTemplateWrapped('Verification_Email', (value) => {
verifyEmailTemplate = value;
});
});
Meteor.methods({
registerUser(formData) {
const AllowAnonymousRead = settings.get('Accounts_AllowAnonymousRead');
Expand Down Expand Up @@ -46,12 +39,14 @@ Meteor.methods({
}

if (settings.get('Accounts_RegistrationForm') === 'Secret URL' && (!formData.secretURL || formData.secretURL !== settings.get('Accounts_RegistrationForm_SecretURL'))) {
if (formData.secretURL) {
try {
validateInviteToken(formData.secretURL);
} catch (e) {
throw new Meteor.Error('error-user-registration-secret', 'User registration is only allowed via Secret URL', { method: 'registerUser' });
}
if (!formData.secretURL) {
throw new Meteor.Error('error-user-registration-secret', 'User registration is only allowed via Secret URL', { method: 'registerUser' });
}

try {
validateInviteToken(formData.secretURL);
} catch (e) {
throw new Meteor.Error('error-user-registration-secret', 'User registration is only allowed via Secret URL', { method: 'registerUser' });
}
}

Expand Down Expand Up @@ -86,11 +81,6 @@ Meteor.methods({
saveCustomFields(userId, formData);

try {
const subject = Mailer.replace(settings.get('Verification_Email_Subject'));

Accounts.emailTemplates.verifyEmail.subject = () => subject;
Accounts.emailTemplates.verifyEmail.html = (userModel, url) => Mailer.replace(Mailer.replacekey(verifyEmailTemplate, 'Verification_Url', url), userModel);

Accounts.sendVerificationEmail(userId, userData.email);
} catch (error) {
// throw new Meteor.Error 'error-email-send-failed', 'Error trying to send email: ' + error.message, { method: 'registerUser', message: error.message }
Expand Down

0 comments on commit 1649daa

Please sign in to comment.