Changeset 6591


Ignore:
Timestamp:
Nov 11, 2014, 7:54:32 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1846: Prevent browser from asking about saving password when login extension doesn't want to

Fixed by making a clone of the main form with only hidden elements which is then submitted instead of the original form. This avoids triggering the dialog in the browser since it has no password-type field.

Location:
trunk/www
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/include/scripts/main-2.js

    r6576 r6591  
    22842284 
    22852285  /**
     2286    Clone the given form and add all elements in it as
     2287    hidden elements in the cloned form. Note that unselected
     2288    checkboxes and radio buttons are not cloned. Selection lists
     2289    with multiple selections are cloned as multiple hidden fields.
     2290  */
     2291  forms.cloneAsHidden = function(frm)
     2292  {
     2293    // Duplicate in hidden form
     2294    var cloned = document.createElement('form');
     2295    cloned.setAttribute('action', frm.action);
     2296    cloned.setAttribute('method', frm.method);
     2297    if (frm.target)
     2298    {
     2299      cloned.setAttribute('target', frm.target);
     2300    }
     2301   
     2302    for (var i = 0; i < frm.elements.length; i++)
     2303    {
     2304      var e = frm.elements[i];
     2305      var shouldClone = e.type == 'text' ||  e.type == 'textarea' || e.type == 'select-one' || e.type == 'password' || e.type == 'hidden';
     2306      shouldClone |= (e.type == 'radio' || e.type == 'checkbox' ) && e.checked;
     2307      if (shouldClone)
     2308      {
     2309        Forms.addHidden(cloned, e.name, e.value);
     2310      }
     2311      else if (e.type == 'select-multiple')
     2312      {
     2313        for (var j = 0; j < e.length; j++)
     2314        {
     2315          if (e[j].selected) Forms.addHidden(cloned, e.name, e[j].value);
     2316        }
     2317      }
     2318    }
     2319    return cloned;
     2320  }
     2321 
     2322  /**
    22862323    Event handler that check/uncheck all checkboxes in a form. The form
    22872324    should be specified in the target element's data-form attribute. The
  • trunk/www/login.js

    r6576 r6591  
    191191   
    192192    if (frm.target) Dialogs.openPopup('', frm.target, 300, 200);
    193     frm.submit();
     193    if (!pUseLastLogin)
     194    {
     195      // Duplicate in hidden form
     196      var frm2 = Forms.cloneAsHidden(frm);
     197      document.body.appendChild(frm2);
     198      frm2.submit();
     199      document.body.removeChild(frm2);
     200    }
     201    else
     202    {
     203      frm.submit();
     204    }
     205   
    194206  }
    195207 
Note: See TracChangeset for help on using the changeset viewer.