(cp 34296598d) fixes #2281 add two default conf for reset and activation link

When a password activation or reset link is generated, the link expiry time is now defined in two conf: $conf[’password_reset_duration‘] with a default time of one hour and $conf[’password_activation_duration‘] with a default time of 72 hours.
This commit is contained in:
Linty
2024-11-25 11:29:39 +01:00
parent 668104d1c7
commit 502ef05df4
10 changed files with 72 additions and 37 deletions
+8 -4
View File
@@ -2215,8 +2215,9 @@ function send_new_user_password(user_id, mail) {
$.ajax({
url: "ws.php?format=json",
dataType: "json",
type: "POST",
data:{
method: 'pwg.users.generateResetPasswordLink',
method: 'pwg.users.generatePasswordLink',
user_id: user_id,
send_by_mail: send_by_mail,
pwg_token: pwg_token
@@ -2228,12 +2229,14 @@ function send_new_user_password(user_id, mail) {
$('#AddUserFieldContainer').hide();
$('#AddUserSuccessContainer').fadeIn();
$('#AddUserPasswordLink').val(response.result.generated_link).trigger('focus');
$('#AddUserTextField').html(send_by_mail ? sprintf(validLinkMail, `<b>${mail}</b>`) : validLinkWithoutMail);
$('#AddUserTextField').html(send_by_mail
? sprintf(validLinkMail, response.result.time_validation, `<b>${mail}</b>`)
: sprintf(validLinkWithoutMail, response.result.time_validation));
if(send_by_mail && !response.result.send_by_mail) {
$('#AddUserUpdated').removeClass('icon-green border-green icon-ok').addClass('icon-red-error icon-cancel');
$('#AddUserUpdatedText').html(errorMailSent);
$('#AddUserTextField').html(errorMailSentMsg);
$('#AddUserTextField').html(sprintf(errorMailSentMsg, response.result.time_validation));
} else if (send_by_mail && response.result.send_by_mail) {
password_container.hide();
}
@@ -2316,8 +2319,9 @@ function send_link_password(email, username, user_id, send_by_mail) {
$.ajax({
url: "ws.php?format=json",
dataType: "json",
type: "POST",
data: {
method: 'pwg.users.generateResetPasswordLink',
method: 'pwg.users.generatePasswordLink',
user_id: user_id,
send_by_mail: send_by_mail,
pwg_token: pwg_token
+2 -2
View File
@@ -45,9 +45,9 @@ const mainUserUpgradeWebmaster = "{'This user must first be defined as the webma
const errorStr = "{'an error happened'|@translate|escape:javascript}";
const copyLinkStr = "{'Copied link'|@translate|escape:javascript}";
const cantCopy = "{'You cannot copy the password if the connection to this site is not secure.'|@translate|escape:javascript}";
const validLinkMail = "{'An activation link valid for 1 hour has been sent to "%s". If the user doesn\'t receive the link, you can generate and copy a new one by editing the user and managing her password.'|@translate|escape:javascript}";
const validLinkMail = "{'An activation link valid for %s has been sent to "%s". If the user doesn\'t receive the link, you can generate and copy a new one by editing the user and managing her password.'|@translate|escape:javascript}";
const validLinkWithoutMail = "{'Copy the link below and send it to the user so the password can be set.'|@translate|escape:javascript}";
const errorMailSentMsg = "{'An activation link valid for 1 hour was created but could not be sent. You can now copy the link below and send it to the user.'|@translate|escape:javascript}";
const errorMailSentMsg = "{'An activation link valid for %s was created but could not be sent. You can now copy the link below and send it to the user.'|@translate|escape:javascript}";
const registered_str = '{"Registered"|@translate|escape:javascript}';
const last_visit_str = '{"Last visit"|@translate|escape:javascript}';