Auto gen password for __PUBLIC__ and hide fields

This commit is contained in:
TimZ99 2020-08-26 15:58:58 +02:00
parent 36e33b3215
commit 99bcc90c03
No known key found for this signature in database
GPG Key ID: 4D8268DC68E8339D
2 changed files with 24 additions and 1 deletions

View File

@ -291,9 +291,16 @@ class UserController extends AbstractController
// always validate password for new users,
// but only validate it for existing users when they change it.
if ($user_id == 0 || ($user_id > 0 && $clean['password'] != '')) {
if (($user_id == 0 || ($user_id > 0 && $clean['password'] != '')) && $clean['user_name'] != '__PUBLIC__') {
$user_validator->password($clean['password'], $clean['password_repeat']);
}
// Auto generate password for __PUBLIC__ user
if ($clean['user_name'] === '__PUBLIC__') {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*_";
$clean['password'] = substr(str_shuffle($chars), 0, 24);
}
if ($user_id > 0) {
$user_validator->userId($user_id);
}

View File

@ -51,6 +51,7 @@ $().ready(function () {
}
$('#label').focus();
});
$("#type").change(function () {
switch ($("select#type option:checked").val()) {
case "website":
@ -103,6 +104,21 @@ $("select#popular_ports").change(function () {
}
}).change();
$("#user_name").change(function ()
{
switch ($("#user_name").val()) {
case "__PUBLIC__":
$('#password').parent().slideUp();
$('#password_repeat').parent().slideUp();
$("select#level").val('30');
$("#name").val('Public page');
break;
default:
$('#password').parent().slideDown();
$('#password_repeat').parent().slideDown();
}
}).change();
function psm_xhr(mod, params, method, on_complete, options) {
method = (typeof method === 'undefined') ? 'GET' : method;