v1.18.x
barisusakli 9 years ago
parent 300996b0d1
commit ac77f78d6b

@ -1,15 +1,14 @@
'use strict';
var async = require('async'),
fs = require('fs'),
nconf = require('nconf'),
winston = require('winston'),
var async = require('async');
var fs = require('fs');
var nconf = require('nconf');
var winston = require('winston');
db = require('../../database'),
user = require('../../user'),
meta = require('../../meta'),
helpers = require('../helpers'),
accountHelpers = require('./helpers');
var db = require('../../database');
var user = require('../../user');
var helpers = require('../helpers');
var accountHelpers = require('./helpers');
var editController = {};
@ -19,7 +18,6 @@ editController.get = function(req, res, callback) {
return callback(err);
}
userData['username:disableEdit'] = !userData.isAdmin && parseInt(meta.config['username:disableEdit'], 10) === 1;
userData.title = '[[pages:account/edit, ' + userData.username + ']]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:edit]]'}]);
@ -44,6 +42,9 @@ function renderRoute(name, req, res, next) {
if (err) {
return next(err);
}
if ((name === 'username' && userData['username:disableEdit']) || (name === 'email' && userData['email:disableEdit'])) {
return next();
}
userData.title = '[[pages:account/edit/' + name + ', ' + userData.username + ']]';
userData.breadcrumbs = helpers.buildBreadcrumbs([
@ -74,7 +75,6 @@ function getUserData(req, next, callback) {
return callback(err);
}
userData['username:disableEdit'] = parseInt(meta.config['username:disableEdit'], 10) === 1;
userData.hasPassword = !!password;
callback(null, userData);
});

@ -1,15 +1,14 @@
'use strict';
var async = require('async'),
validator = require('validator'),
nconf = require('nconf'),
var async = require('async');
var validator = require('validator');
user = require('../../user'),
groups = require('../../groups'),
plugins =require('../../plugins'),
meta = require('../../meta'),
utils = require('../../../public/src/utils');
var user = require('../../user');
var groups = require('../../groups');
var plugins =require('../../plugins');
var meta = require('../../meta');
var utils = require('../../../public/src/utils');
var helpers = {};
@ -103,6 +102,8 @@ helpers.getUserDataByUserSlug = function(userslug, callerUID, callback) {
userData['cover:url'] = userData['cover:url'] || require('../../coverPhoto').getDefaultProfileCover(userData.uid);
userData['cover:position'] = userData['cover:position'] || '50% 50%';
userData['username:disableEdit'] = !userData.isAdmin && parseInt(meta.config['username:disableEdit'], 10) === 1;
userData['email:disableEdit'] = !userData.isAdmin && parseInt(meta.config['email:disableEdit'], 10) === 1;
next(null, userData);
}

@ -127,6 +127,10 @@ module.exports = function(SocketUser) {
data.username = oldUserData.username;
}
if (!isAdmin && parseInt(meta.config['email:disableEdit'], 10) === 1) {
data.email = oldUserData.email;
}
user.updateProfile(data.uid, data, next);
},
function (userData, next) {

@ -66,6 +66,12 @@
<span class="mdl-switch__label"><strong>Disable username changes</strong></span>
</label>
</div>
<div class="checkbox">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" data-field="email:disableEdit">
<span class="mdl-switch__label"><strong>Disable email changes</strong></span>
</label>
</div>
<div class="checkbox">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" data-field="allowAccountDelete" checked>

Loading…
Cancel
Save