Debian Codegraph @

doc/sources/admin/jqueryevents.rst

raw
1 Available JQuery Events
2 ========================
3
4 Some portal functions (such as 2FA registration) are performed by Javascript.
5
6 We offer a few custom events that let you react to certain high-level Javascript events
7
8 Preventing default behavior
9 ---------------------------
10
11 .. versionadded:: 2.17
12
13 Event handlers can stop the default LemonLDAP::NG behavior from executing:
14
15 .. code:: javascript
16
17 $(document).on( "sslFailure", { }, function( event ) {
18 event.preventDefault();
19 // Navigate the user to the smartcard help page, etc.
20 });
21
22
23 Second factor management
24 ------------------------
25
26 mfaAdded
27 ~~~~~~~~
28
29 .. versionadded:: 2.0.15
30
31 This event is triggered when a TOTP or WebAuthn device is registered
32
33 Sample code:
34
35 .. code:: javascript
36
37 $(document).on( "mfaAdded", { }, function( event, info ) {
38 console.log( "Added MFA of type" + info.type );
39 // Your code here
40
41 // If you want to prevent the redirection to the 2FA register page
42 // event.preventDefault();
43 });
44
45 .. versionchanged:: 2.0.16
46
47 LemonLDAP::NG redirects to the 2FA Register page after your
48 device has been added. You can cancel this redirection by calling
49 ``event.preventDefault()`` in your listener.
50
51 mfaDeleted
52 ~~~~~~~~~~~
53
54 .. versionadded:: 2.0.15
55
56 This event is triggered when a TOTP or WebAuthn device is removed
57
58 Sample code:
59
60 .. code:: javascript
61
62 $(document).on( "mfaDeleted", { }, function( event, info ) {
63 console.log( "Removed MFA of type" + info.type );
64 // Your code here
65 });
66
67 mfaUpdated
68 ~~~~~~~~~~~
69
70 .. versionadded:: 2.23.0
71
72 This event is triggered when a TOTP or WebAuthn device name is updated
73
74 Sample code:
75
76 .. code:: javascript
77
78 $(document).on( "mfaUpdated", { }, function( event, info ) {
79 console.log( "Updated MFA of type" + info.type + " with a new label " + info.label);
80 // Your code here
81 });
82
83 UI
84 --
85
86 portalLoaded
87 ~~~~~~~~~~~~
88 .. versionadded:: 2.0.16
89
90 This even is triggered after the main portal javascript has run
91
92 Sample code:
93
94 .. code:: javascript
95
96
97 $(document).on( "portalLoaded", { }, function( event, info ) {
98 // Make sure DOM is ready as well
99 $( document ).ready(function() {
100 console.log("Portal loaded and DOM ready");
101 });
102 });
103
104
105
106 Authentication
107 --------------
108
109 kerberosAttempt
110 ~~~~~~~~~~~~~~~
111
112 .. versionadded:: 2.17
113
114 This even is triggered immediately before the user tries to authenticate using Kerberos
115
116 .. code:: javascript
117
118 $(document).on( "kerberosAttempt", { }, function( event ) {
119 console.log( "Kerberos attempt" );
120 });
121
122 kerberosFailure
123 ~~~~~~~~~~~~~~~
124
125 .. versionadded:: 2.17
126
127 This even is triggered when the user failed to authenticate using Kerberos
128
129 .. code:: javascript
130
131 $(document).on( "kerberosFailure", { }, function( event , info ) {
132 console.log( "Kerberos failure", info );
133 });
134
135 kerberosSuccess
136 ~~~~~~~~~~~~~~~
137
138 .. versionadded:: 2.17
139
140 This even is triggered when before the user successfully authenticated using Kerberos
141
142 .. code:: javascript
143
144 $(document).on( "kerberosSuccess", { }, function( event , info ) {
145 console.log( "Kerberos success", info );
146 });
147
148 sslAttempt
149 ~~~~~~~~~~
150
151 .. versionadded:: 2.17
152
153 This even is triggered immediately before the user tries to authenticate using SSL
154
155 .. code:: javascript
156
157 $(document).on( "sslAttempt", { }, function( event ) {
158 console.log( "SSL attempt" );
159 });
160
161 sslFailure
162 ~~~~~~~~~~
163
164 .. versionadded:: 2.17
165
166 This even is triggered when the user failed to authenticate using SSL
167
168 .. code:: javascript
169
170 $(document).on( "sslFailure", { }, function( event , info ) {
171 console.log( "SSL failure", info );
172 });
173
174 sslSuccess
175 ~~~~~~~~~~
176
177 .. versionadded:: 2.17
178
179 This even is triggered when before the user successfully authenticated using SSL
180
181 .. code:: javascript
182
183 $(document).on( "sslSuccess", { }, function( event , info ) {
184 console.log( "SSL success", info );
185 });
186
187
188 webauthnAttempt
189 ~~~~~~~~~~~~~~~
190
191 .. versionadded:: 2.17
192
193 This even is triggered immediately before the user tries to use a WebAuthn device
194
195 .. code:: javascript
196
197 $(document).on( "webauthnAttempt", { }, function( event ) {
198 console.log( "WebAuthn attempt" );
199 });
200
201 webauthnFailure
202 ~~~~~~~~~~~~~~~
203
204 .. versionadded:: 2.17
205
206 This even is triggered when the user failed to use a WebAuthn device
207
208 .. code:: javascript
209
210 $(document).on( "webauthnFailure", { }, function( event , info ) {
211 console.log( "WebAuthn failure", info );
212 });
213
214 webauthnSuccess
215 ~~~~~~~~~~~~~~~
216
217 .. versionadded:: 2.17
218
219 This even is triggered when the user successfully used a WebAuthn device
220
221 .. code:: javascript
222
223 $(document).on( "webauthnSuccess", { }, function( event , info ) {
224 console.log( "WebAuthn success", info );
225 });
226
227 webauthnRegistrationAttempt
228 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
229
230 .. versionadded:: 2.17
231
232 This even is triggered immediately before the user tries to register a WebAuthn device
233
234 .. code:: javascript
235
236 $(document).on( "webauthnRegistrationAttempt", { }, function( event ) {
237 console.log( "WebAuthn registration attempt" );
238 });
239
240 webauthnRegistrationFailure
241 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
242
243 .. versionadded:: 2.17
244
245 This even is triggered when the user failed to register a WebAuthn device
246
247 .. code:: javascript
248
249 $(document).on( "webauthnRegistrationFailure", { }, function( event , info ) {
250 console.log( "WebAuthn registration failure", info );
251 });
252
253 webauthnRegistrationSuccess
254 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
255
256 .. versionadded:: 2.17
257
258 This even is triggered when the user successfully registered a WebAuthn device
259
260 .. code:: javascript
261
262 $(document).on( "webauthnRegistrationSuccess", { }, function( event , info ) {
263 console.log( "WebAuthn registration success", info );
264 });
265
266 Password policy
267 ---------------
268
269 .. _checkpassword:
270
271 checkpassword
272 ~~~~~~~~~~~~~
273
274 .. versionadded:: 2.18
275
276 This event is triggered on every keystroke while the user inputs a new
277 password. You can use it to check if it fits certain criteria.
278
279 You can fetch the candidate password in ``context.password``.
280
281 ``context.evType`` will contain ``focusout`` if the user has focused out of the
282 password field. You can use it for costly password quality checks to avoid
283 running the check at every keystroke.
284
285 ``context.setResult`` is a function that you can call to update the password form state.
286
287 * Its first argument is the ``id`` of the policy that you added with ``addPasswordPolicy`` in the server-side code.
288 * Its second argument is the state of the policy, you can use one of ``good``, ``bad``, ``unknown``, ``waiting`` or ``info``.
289
290 The new password form can only be submitted when all policies have been set to a status of either ``good`` or ``info``.
291
292 .. code:: javascript
293
294 $(document).on( "checkpassword", function( event , context ) {
295 password = context.password;
296 evType = context.evType;
297 setResult = context.setResult;
298
299 // Do your client-side check here
300 setResult("my-custom-ppolicy", "bad");
301 });