Adds autocomplete option to settings fields (#10439)

[NEW] Prevent the browser to autocomplete some setting fields
pull/10225/head^2
Gabriel Delavald 8 years ago committed by Rodrigo Nascimento
parent 5cdcda8818
commit f6a08e6b95
  1. 3
      packages/rocketchat-lib/server/functions/settings.js
  2. 6
      packages/rocketchat-lib/server/startup/settings.js
  3. 18
      packages/rocketchat-ui-admin/client/admin.html
  4. 7
      packages/rocketchat-ui-admin/client/admin.js

@ -74,6 +74,9 @@ RocketChat.settings.add = function(_id, value, options = {}) {
if (hiddenSettings[_id] != null) { if (hiddenSettings[_id] != null) {
options.hidden = true; options.hidden = true;
} }
if (options.autocomplete == null) {
options.autocomplete = true;
}
if (typeof process !== 'undefined' && process.env && process.env[`OVERWRITE_SETTING_${ _id }`]) { if (typeof process !== 'undefined' && process.env && process.env[`OVERWRITE_SETTING_${ _id }`]) {
let value = process.env[`OVERWRITE_SETTING_${ _id }`]; let value = process.env[`OVERWRITE_SETTING_${ _id }`];
if (value.toLowerCase() === 'true') { if (value.toLowerCase() === 'true') {

@ -1006,12 +1006,14 @@ RocketChat.settings.addGroup('Email', function() {
this.add('SMTP_Username', '', { this.add('SMTP_Username', '', {
type: 'string', type: 'string',
env: true, env: true,
i18nLabel: 'Username' i18nLabel: 'Username',
autocomplete: false
}); });
this.add('SMTP_Password', '', { this.add('SMTP_Password', '', {
type: 'password', type: 'password',
env: true, env: true,
i18nLabel: 'Password' i18nLabel: 'Password',
autocomplete: false
}); });
this.add('From_Email', '', { this.add('From_Email', '', {
type: 'string', type: 'string',

@ -56,25 +56,25 @@
{{#if multiline}} {{#if multiline}}
<textarea class="input-monitor rc-input__element" name="{{_id}}" rows="4" style="height: auto" {{isDisabled}} {{isReadonly}}>{{value}}</textarea> <textarea class="input-monitor rc-input__element" name="{{_id}}" rows="4" style="height: auto" {{isDisabled}} {{isReadonly}}>{{value}}</textarea>
{{else}} {{else}}
<input class="input-monitor rc-input__element" type="text" name="{{_id}}" value="{{value}}" placeholder="{{placeholder}}" {{isDisabled}} {{isReadonly}}/> <input class="input-monitor rc-input__element" type="text" name="{{_id}}" value="{{value}}" placeholder="{{placeholder}}" {{isDisabled}} {{isReadonly}} {{canAutocomplete}}/>
{{/if}} {{/if}}
{{/if}} {{/if}}
{{#if $eq type 'relativeUrl'}} {{#if $eq type 'relativeUrl'}}
<input class="input-monitor rc-input__element" type="text" name="{{_id}}" value="{{relativeUrl value}}" placeholder="{{placeholder}}" {{isDisabled}} {{isReadonly}}/> <input class="input-monitor rc-input__element" type="text" name="{{_id}}" value="{{relativeUrl value}}" placeholder="{{placeholder}}" {{isDisabled}} {{isReadonly}} {{canAutocomplete}}/>
{{/if}} {{/if}}
{{#if $eq type 'password'}} {{#if $eq type 'password'}}
<input class="input-monitor rc-input__element" type="password" name="{{_id}}" value="{{value}}" placeholder="{{placeholder}}" {{isDisabled}} {{isReadonly}}/> <input class="input-monitor rc-input__element" type="password" name="{{_id}}" value="{{value}}" placeholder="{{placeholder}}" {{isDisabled}} {{isReadonly}} {{canAutocomplete}}/>
{{/if}} {{/if}}
{{#if $eq type 'int'}} {{#if $eq type 'int'}}
<input class="input-monitor rc-input__element" type="number" name="{{_id}}" value="{{value}}" placeholder="{{placeholder}}" {{isDisabled}} {{isReadonly}}/> <input class="input-monitor rc-input__element" type="number" name="{{_id}}" value="{{value}}" placeholder="{{placeholder}}" {{isDisabled}} {{isReadonly}} {{canAutocomplete}}/>
{{/if}} {{/if}}
{{#if $eq type 'boolean'}} {{#if $eq type 'boolean'}}
<label><input class="input-monitor" type="radio" name="{{_id}}" value="1" checked="{{$eq value true}}" {{isDisabled}} {{isReadonly}}/> {{_ "True"}}</label> <label><input class="input-monitor" type="radio" name="{{_id}}" value="1" checked="{{$eq value true}}" {{isDisabled}} {{isReadonly}} {{canAutocomplete}}/> {{_ "True"}}</label>
<label><input class="input-monitor" type="radio" name="{{_id}}" value="0" checked="{{$eq value false}}" {{isDisabled}} {{isReadonly}}/> {{_ "False"}}</label> <label><input class="input-monitor" type="radio" name="{{_id}}" value="0" checked="{{$eq value false}}" {{isDisabled}} {{isReadonly}} {{canAutocomplete}}/> {{_ "False"}}</label>
{{/if}} {{/if}}
{{#if $eq type 'select'}} {{#if $eq type 'select'}}
@ -103,7 +103,7 @@
{{/if}} {{/if}}
{{#if $eq editor 'expression'}} {{#if $eq editor 'expression'}}
<div class="flex-grow-1"> <div class="flex-grow-1">
<input class="input-monitor rc-input__element" type="text" name="{{_id}}" value="{{value}}" {{isDisabled}}/> <input class="input-monitor rc-input__element" type="text" name="{{_id}}" value="{{value}}" {{isDisabled}} {{canAutocomplete}}/>
</div> </div>
{{/if}} {{/if}}
<div class="color-editor "> <div class="color-editor ">
@ -118,7 +118,7 @@
{{/if}} {{/if}}
{{#if $eq type 'font'}} {{#if $eq type 'font'}}
<input class="input-monitor rc-input__element" type="text" name="{{_id}}" value="{{value}}" {{isDisabled}} {{isReadonly}}/> <input class="input-monitor rc-input__element" type="text" name="{{_id}}" value="{{value}}" {{isDisabled}} {{isReadonly}} {{canAutocomplete}}/>
{{/if}} {{/if}}
{{#if $eq type 'code'}} {{#if $eq type 'code'}}
@ -143,7 +143,7 @@
{{#if hasChanges section}} {{#if hasChanges section}}
<span style="line-height: 40px" class="secondary-font-color">{{_ "Save_to_enable_this_action"}}</span> <span style="line-height: 40px" class="secondary-font-color">{{_ "Save_to_enable_this_action"}}</span>
{{else}} {{else}}
<button type="button" class="button primary action" data-setting="{{_id}}" data-action="{{value}}" {{isDisabled}}>{{_ actionText}}</button> <button type="button" class="button primary action" data-setting="{{_id}}" data-action="{{value}}" {{isDisabled}} >{{_ actionText}}</button>
{{/if}} {{/if}}
{{/if}} {{/if}}

@ -191,6 +191,13 @@ Template.admin.helpers({
}; };
} }
}, },
canAutocomplete() {
if (this.autocomplete === false) {
return {
autocomplete: 'off'
};
}
},
hasChanges(section) { hasChanges(section) {
const group = FlowRouter.getParam('group'); const group = FlowRouter.getParam('group');
const query = { const query = {

Loading…
Cancel
Save