Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ajax/mailcollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@

if (!empty($input['mail_server'])) {
$input["host"] = Toolbox::constructMailServerConfig($input);
if (!isset($input['passwd'])) {
// In some case (like oauth imap) provide password is not possible
// So, ask for password only if there is one stored in database
if (!isset($input['passwd']) && !empty($mailcollector->fields['passwd'])) {
$exception = new AccessDeniedHttpException();
$exception->setMessageToDisplay(__('Password is required to list mail folders.'));
throw $exception;
Expand Down
11 changes: 7 additions & 4 deletions templates/pages/setup/mailcollector/setup_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,13 @@
// Force empty value for server_mailbox
data += '&server_mailbox=';

// Ask for password if missing
if ($(this).closest('form').find('input[name=\"passwd\"]').val() == '') {
var passwd = prompt(__('Please enter password to list folders'));
data += '&passwd=' + encodeURIComponent(passwd);
// In some case (like oauth imap) provide password is not possible
// So, ask for password only if there is one stored in database
var passwdField = $(this).closest('form').find('input[name="passwd"]');
var hasStoredPassword = {{ (item.fields['passwd'] is defined and item.fields['passwd']) ? 'true' : 'false' }};
if (hasStoredPassword && passwdField.val() == '') {
var passwd = prompt(__('Please enter password to list folders'));
data += '&passwd=' + encodeURIComponent(passwd);
}

glpi_ajax_dialog({
Expand Down
Loading