diff --git a/admin/themes/default/js/user_list.js b/admin/themes/default/js/user_list.js index 89b2883c0..2b3833983 100644 --- a/admin/themes/default/js/user_list.js +++ b/admin/themes/default/js/user_list.js @@ -2191,7 +2191,7 @@ function add_infos_to_new_user(user_id, ajax_data) { // add_user_close(); $('#AddUserUpdated').removeClass('icon-red icon-cancel').addClass('icon-green border-green icon-ok'); $('#AddUserUpdatedText').html(user_added_str.replace("%s", ajax_data.username)); - send_new_user_password(new_user_id, ajax_data.email === '' ? false : true); + send_new_user_password(new_user_id, ajax_data.email); $("#AddUser .user-property-input").val(""); $("#AddUserSuccess .edit-now").off("click").on("click", () => { last_user_id = new_user_id; @@ -2215,7 +2215,8 @@ function add_infos_to_new_user(user_id, ajax_data) { }); } -function send_new_user_password(user_id, send_by_mail) { +function send_new_user_password(user_id, mail) { + let send_by_mail = mail === '' ? false : true; $.ajax({ url: "ws.php?format=json", dataType: "json", @@ -2227,14 +2228,19 @@ function send_new_user_password(user_id, send_by_mail) { }, success: function(response) { if('ok' === response.stat) { + const password_container = $('#AddUserPasswordInputContainer'); + password_container.show(); $('#AddUserFieldContainer').hide(); $('#AddUserSuccessContainer').fadeIn(); $('#AddUserPasswordLink').val(response.result.generated_link).trigger('focus'); - $('#AddUserTextField').html(send_by_mail ? validLinkMail : validLinkWithoutMail); + $('#AddUserTextField').html(send_by_mail ? sprintf(validLinkMail, `${mail}`) : validLinkWithoutMail); 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); + } else if (send_by_mail && response.result.send_by_mail) { + password_container.hide(); } if (window.isSecureContext && navigator.clipboard) { diff --git a/admin/themes/default/template/user_list.tpl b/admin/themes/default/template/user_list.tpl index 5272d54b8..f240741cd 100644 --- a/admin/themes/default/template/user_list.tpl +++ b/admin/themes/default/template/user_list.tpl @@ -45,8 +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 = "{'A link, valid for 3 days has already been sent. If the email fails, copy the link below and send it to the user so the password can be set.'|@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 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 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 registered_str = '{"Registered"|@translate|escape:javascript}'; const last_visit_str = '{"Last visit"|@translate|escape:javascript}'; @@ -1222,8 +1223,8 @@ $(document).ready(function() {