Changeset 8035


Ignore:
Timestamp:
May 25, 2022, 7:48:39 AM (9 months ago)
Author:
Nicklas Nordborg
Message:

References #2278: Improvements to login page for better extensions

Implemented a custom event before-login that is sent to the <form> element on the login page just before it is about to be submitted. Extensions may register for this event and may call event.preventDefault() to prevent the submission. A new method Login.submitLoginForm() can be called to submit the form without any more questions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.19-stable/www/login.js

    r7815 r8035  
    305305      }
    306306    }
     307   
     308    // Send custom event to let extensions do stuff before submitting
     309    var evt = new CustomEvent('before-login', { cancelable: true, bubbles: true });
     310    if (frm.dispatchEvent(evt))
     311    {
     312      login.submitLoginForm();
     313    }
     314  }
     315 
     316  /**
     317    Submit the login form with no questions asked.
     318  */
     319  login.submitLoginForm = function()
     320  {
     321    var frm = document.forms['login'];
    307322    if (!pUseLastLogin)
    308323    {
     
    317332      frm.submit();
    318333    }
    319    
    320334  }
    321335 
Note: See TracChangeset for help on using the changeset viewer.