Commit a1ce3280 authored by Luc Didry's avatar Luc Didry

Add an option to force users to use the first and last name as pad login

This commit is dedicated to Schoumi, who is supporting me on Tipeee. Many thanks :-)
parent 83e94eef
Pipeline #41197 passed with stage
in 34 seconds
......@@ -486,6 +486,20 @@ module.exports = (function () {
app.delete(confRoute + '/:key', fn.ensureAdmin,
ld.partial(fn.del, conf.del));
/**
* GET method
*
* Return the value of useFirstLastNameInPads configuration setting
*
* Sample URL:
* http://etherpad.ndd/mypads/api/configuration/public/usefirstlastname
*/
app.get(confRoute + '/public/usefirstlastname', function (req, res) {
return res.send({ success: true, usefirstlastname: conf.get('useFirstLastNameInPads') });
});
};
/**
......@@ -1277,7 +1291,6 @@ module.exports = (function () {
* http://etherpad.ndd/mypads/api/pad/ispublic/xxxx
*/
// TODO: + admin, no pass needed...
app.get(padRoute + '/ispublic/:key', function (req, res) {
pad.get(req.params.key, function(err, p) {
if (err) {
......
......@@ -67,7 +67,8 @@ module.exports = (function() {
SMTPEmailFrom: undefined,
SMTPSSL: false,
SMTPTLS: true,
tokenDuration: 60 // in minutes
tokenDuration: 60, // in minutes
useFirstLastNameInPads: false
},
/**
......@@ -227,7 +228,7 @@ module.exports = (function() {
public: function () {
var all = configuration.all();
return ld.pick(all, 'title', 'passwordMin', 'passwordMax', 'languages',
'HTMLExtraHead', 'openRegistration', 'hideHelpBlocks');
'HTMLExtraHead', 'openRegistration', 'hideHelpBlocks', 'useFirstLastNameInPads');
}
};
......
......@@ -64,7 +64,7 @@ module.exports = (function () {
'passwordMin', 'passwordMax', 'defaultLanguage', 'checkMails',
'tokenDuration', 'SMTPHost', 'SMTPPort', 'SMTPSSL', 'SMTPTLS',
'SMTPUser', 'SMTPPass', 'SMTPEmailFrom', 'HTMLExtraHead',
'openRegistration', 'hideHelpBlocks']);
'openRegistration', 'hideHelpBlocks', 'useFirstLastNameInPads']);
c.currentConf = resp.value;
ld.forIn(resp.value, function (v, k) {
c.data[k] = m.prop(v);
......@@ -323,6 +323,23 @@ module.exports = (function () {
var l = m('label', [ f, A.FIELD.HIDE_HELP_BLOCKS, icon ]);
return l;
})(),
useFirstLastNameInPads: (function () {
var icon = form.icon(c, 'useFirstLastNameInPads', A.INFO.USE_FIRST_AND_LAST_NAME_IN_PADS);
var opts = {
name: 'useFirstLastNameInPads',
};
if (c.data.useFirstLastNameInPads) {
opts['checked'] = 'checked';
}
var f = m('input[type="checkbox"]', opts);
ld.assign(f.attrs, {
type: 'checkbox',
checked: c.data.useFirstLastNameInPads(),
onchange: m.withAttr('checked', c.data.useFirstLastNameInPads)
});
var l = m('label', [ f, A.FIELD.USE_FIRST_AND_LAST_NAME_IN_PADS, icon ]);
return l;
})(),
openRegistration: (function () {
var icon = form.icon(c, 'openRegistration', A.INFO.OPEN_REGISTRATION);
var opts = {
......@@ -441,6 +458,7 @@ module.exports = (function () {
m('div.checkbox', [ f.allowEtherPads ]),
m('div.checkbox', [ f.openRegistration ]),
m('div.checkbox', [ f.hideHelpBlocks ]),
m('div.checkbox', [ f.useFirstLastNameInPads ]),
m('div.form-group', [ f.HTMLExtraHead.label, f.HTMLExtraHead.icon, f.HTMLExtraHead.textarea ])
])
]),
......
......@@ -260,7 +260,7 @@ module.exports = (function () {
return memo;
}, [])
);
return { label: label, icon: icon, select: select };
return { label: label, select: select };
};
/**
......@@ -276,12 +276,12 @@ module.exports = (function () {
checked: c.data.useLoginAndColorInPads(),
onchange: m.withAttr('checked', c.data.useLoginAndColorInPads)
}),
conf.LANG.USER.USELOGINANDCOLORINPADS
((conf.SERVER.useFirstLastNameInPads) ? conf.LANG.USER.USECOLORINPADS : conf.LANG.USER.USELOGINANDCOLORINPADS),
m('i',{
class: 'mp-tooltip glyphicon glyphicon-info-sign',
'data-msg': ((conf.SERVER.useFirstLastNameInPads) ? conf.LANG.USER.INFO.USECOLORINPADS : conf.LANG.USER.INFO.USELOGINANDCOLORINPADS)
}),
]),
icon: m('i',{
class: 'mp-tooltip glyphicon glyphicon-info-sign',
'data-msg': conf.LANG.USER.INFO.USELOGINANDCOLORINPADS
}),
};
};
......
......@@ -252,6 +252,11 @@ module.exports = (function () {
var u = auth.fn.getUser(token);
if (u && u.useLoginAndColorInPads) {
var opts = { userName: u.login };
if (conf.get('useFirstLastNameInPads')) {
var firstname = (u.firstname) ? u.firstname : '';
var lastname = (u.lastname) ? u.lastname : '';
opts.userName = firstname+' '+lastname;
}
if (u.color) {
opts.userColor = u.color;
}
......
......@@ -566,6 +566,21 @@
);
});
describe('configuration.public GET usefirstlastname', function () {
it('should return the value of useFirstLastNameInPads',
function (done) {
rq.get(confRoute + '/public/usefirstlastname', function (err, resp, body) {
expect(resp.statusCode).toBe(200);
expect(body.success).toBeTruthy();
expect(body.usefirstlastname).toBeDefined();
done();
});
}
);
});
});
describe('user inactive account limitations', function () {
......
......@@ -548,6 +548,21 @@
);
});
describe('configuration.public GET usefirstlastname', function () {
it('should return the value of useFirstLastNameInPads',
function (done) {
rq.get(confRoute + '/public/usefirstlastname', function (err, resp, body) {
expect(resp.statusCode).toBe(200);
expect(body.success).toBeTruthy();
expect(body.usefirstlastname).toBeDefined();
done();
});
}
);
});
});
describe('user inactive account limitations', function () {
......
......@@ -145,6 +145,7 @@
expect(settings.HTMLExtraHead).toBeDefined();
expect(settings.openRegistration).toBeDefined();
expect(settings.hideHelpBlocks).toBeDefined();
expect(settings.useFirstLastNameInPads).toBeDefined();
done();
});
});
......
......@@ -90,4 +90,18 @@ exports.postToolbarInit = function (hook_name, args) {
}
}
});
/*
* Prevents users from changing their nickname if useFirstLastNameInPads is set
*/
$.ajax({
method: 'GET',
url: baseURL+'/mypads/api/configuration/public/usefirstlastname',
dataType: 'JSON',
success: function(data, textStatus, jqXHR) {
if (data.success && data.usefirstlastname) {
$('#myusernameedit').prop('disabled', true);
}
}
});
}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -138,6 +138,7 @@
"EMAIL_SAMPLE": "username@example.org",
"LANG": "Language",
"USELOGINANDCOLORINPADS": "Use login and color in pads?",
"USECOLORINPADS": "Use color in pads?",
"FIRSTNAME": "Firstname",
"LASTNAME": "Lastname",
"ORGANIZATION": "Organization",
......@@ -153,7 +154,8 @@
"EMAIL": "The email is required for password recovery",
"COLOR": "The hexademical code for color you want to be used by default in pads",
"LANG": "Your default browser configuration, depending on available languages on MyPads",
"USELOGINANDCOLORINPADS": "Use login and chosen color in pads by default ?",
"USELOGINANDCOLORINPADS": "Use login and chosen color in pads by default?",
"USECOLORINPADS": "Use chosen color in pads by default?",
"PASSWORD_BEGIN": "Must be between ",
"PASSWORD_END": " characters",
"PASSWORD_CHECK": "For verification : must be the same as password",
......@@ -362,6 +364,7 @@
"ALLOW_ETHERPADS": "Anonymous pads",
"OPEN_REGISTRATION": "Open registration",
"HIDE_HELP_BLOCKS": "Hide help blocks",
"USE_FIRST_AND_LAST_NAME_IN_PADS": "Use first and last name of users as nickname in pads",
"CHECKMAILS": "Check user mails",
"TOKEN_DURATION": "Token validity",
"SMTP_HOST": "SMTP Host",
......@@ -385,6 +388,7 @@
"ALLOW_ETHERPADS": "Allow classic anonymous pads from on the Etherpad instance, created from the root URL of the server",
"OPEN_REGISTRATION": "Allow anyone to create an account (no effect if the LDAP authentication is set)",
"HIDE_HELP_BLOCKS": "Help blocks shows in multiple MyPads pages, you can hide them with this setting",
"USE_FIRST_AND_LAST_NAME_IN_PADS": "Force the use of first and last name as nickname in pads",
"CHECKMAILS": "Check user mail given at subscription",
"TOKEN_DURATION": "The time, in minutes, generated tokens are valid until users confirm their subscription",
"SMTP_HOST": "Domain name where the SMTP Server belongs to",
......
......@@ -138,6 +138,7 @@
"EMAIL_SAMPLE": "identifiant@exemple.org",
"LANG": "Langue",
"USELOGINANDCOLORINPADS": "Identifiant et couleur dans les pads ?",
"USECOLORINPADS": "Couleur dans les pads ?",
"FIRSTNAME": "Prénom",
"LASTNAME": "Nom",
"ORGANIZATION": "Organisation",
......@@ -154,6 +155,7 @@
"COLOR": "Le code hexadécimal pour la couleur que vous souhaitez utiliser par défaut pour les pads",
"LANG": "Selon la configuration de votre navigateur par défaut, dépend de ceux disponibles sur MyPads",
"USELOGINANDCOLORINPADS": "Utiliser votre identifiant et votre couleur dans les pads par défaut ?",
"USECOLORINPADS": "Utiliser la couleur choisie dans les pads par défaut ?",
"PASSWORD_BEGIN": "Doit être compris entre ",
"PASSWORD_END": " caractères",
"PASSWORD_CHECK": "Pour confirmer : doit être le même que le mot de passe",
......@@ -362,6 +364,7 @@
"ALLOW_ETHERPADS": "Pads anonymes",
"OPEN_REGISTRATION": "Inscriptions ouvertes",
"HIDE_HELP_BLOCKS": "Cacher les blocs d'aide",
"USE_FIRST_AND_LAST_NAME_IN_PADS": "Utiliser le prénom et le nom comme identifiant dans les pads",
"CHECKMAILS": "Vérifier les mails",
"TOKEN_DURATION": "Validité des jetons",
"SMTP_HOST": "Hôte SMTP",
......@@ -385,6 +388,7 @@
"ALLOW_ETHERPADS": "Autoriser les pads anonymes classiques sur l'instance Etherpad, pads créés à partir de l'adresse racine du serveur",
"OPEN_REGISTRATION": "Permettre à tout un chacun de se créer un compte (sans effet si l'authentification LDAP est utilisée)",
"HIDE_HELP_BLOCKS": "Des blocs d'aide sont affichés dans de multiples pages de MyPads, vous pouvez les cacher avec ce paramètre de configuration",
"USE_FIRST_AND_LAST_NAME_IN_PADS": "Force l’utilisation du prénom et du nom des utilisateurs dans les pads",
"CHECKMAILS": "Vérification des adresses mails données par les utilisateurs lors de leur inscription",
"TOKEN_DURATION": "Le temps, en minutes, pendant lequel les jetons générés sont valides, afin que les utilisateurs puissent confirmer leur adresse mail",
"SMTP_HOST": "Le nom de domaine sur lequel pointer pour le serveur SMTP",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment