keycloakify 7.12.5 → 7.12.6-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account/kcContext/KcContext.d.ts +26 -1
- package/account/kcContext/KcContext.js.map +1 -1
- package/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +354 -66
- package/login/kcContext/KcContext.d.ts +26 -1
- package/login/kcContext/KcContext.js.map +1 -1
- package/package.json +1 -1
- package/src/account/kcContext/KcContext.ts +26 -1
- package/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +354 -66
- package/src/login/kcContext/KcContext.ts +26 -1
@@ -46,9 +46,34 @@ export declare namespace KcContext {
|
|
46
46
|
name: string;
|
47
47
|
};
|
48
48
|
messagesPerField: {
|
49
|
-
|
49
|
+
/**
|
50
|
+
* Return text if message for given field exists. Useful eg. to add css styles for fields with message.
|
51
|
+
*
|
52
|
+
* @param fieldName to check for
|
53
|
+
* @param text to return
|
54
|
+
* @return text if message exists for given field, else undefined
|
55
|
+
*/
|
56
|
+
printIfExists: <T extends string>(fieldName: string, text: T) => T | undefined;
|
57
|
+
/**
|
58
|
+
* Check if exists error message for given fields
|
59
|
+
*
|
60
|
+
* @param fields
|
61
|
+
* @return boolean
|
62
|
+
*/
|
50
63
|
existsError: (fieldName: string) => boolean;
|
64
|
+
/**
|
65
|
+
* Get message for given field.
|
66
|
+
*
|
67
|
+
* @param fieldName
|
68
|
+
* @return message text or empty string
|
69
|
+
*/
|
51
70
|
get: (fieldName: string) => string;
|
71
|
+
/**
|
72
|
+
* Check if message for given field exists
|
73
|
+
*
|
74
|
+
* @param field
|
75
|
+
* @return boolean
|
76
|
+
*/
|
52
77
|
exists: (fieldName: string) => boolean;
|
53
78
|
};
|
54
79
|
account: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KcContext.js","sourceRoot":"","sources":["../../src/account/kcContext/KcContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"KcContext.js","sourceRoot":"","sources":["../../src/account/kcContext/KcContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAgHtC;IAOI,MAAM,EAA4B,CAAC;IACnC,MAAM,EAAiC,CAAC;CAC3C;AAED,MAAM,EAA2D,CAAC"}
|
@@ -28,85 +28,373 @@
|
|
28
28
|
<#recover>
|
29
29
|
</#attempt>
|
30
30
|
|
31
|
-
"printIfExists": function (fieldName,
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
"printIfExists": function (fieldName, text) {
|
32
|
+
|
33
|
+
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
34
|
+
throw new Error("You're not supposed to use messagesPerField.printIfExists in this page");
|
35
|
+
</#if>
|
36
|
+
|
37
|
+
<#list fieldNames as fieldName>
|
38
|
+
if(fieldName === "${fieldName}" ){
|
39
|
+
|
40
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/359 Compat with Keycloak prior v12 -->
|
41
|
+
<#if !messagesPerField.existsError??>
|
42
|
+
|
43
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
44
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
45
|
+
|
46
|
+
<#local doExistMessageForUsernameOrPassword = "">
|
47
|
+
|
48
|
+
<#attempt>
|
49
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('username')>
|
50
|
+
<#recover>
|
51
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
52
|
+
</#attempt>
|
53
|
+
|
54
|
+
<#if !doExists>
|
55
|
+
<#attempt>
|
56
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('password')>
|
57
|
+
<#recover>
|
58
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
59
|
+
</#attempt>
|
60
|
+
</#if>
|
61
|
+
|
62
|
+
return <#if doExistMessageForUsernameOrPassword>text<#else>undefined</#if>;
|
63
|
+
|
64
|
+
<#else>
|
65
|
+
|
66
|
+
<#local doExistMessageForField = "">
|
67
|
+
|
68
|
+
<#attempt>
|
69
|
+
<#local doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
70
|
+
<#recover>
|
71
|
+
<#local doExistMessageForField = true>
|
72
|
+
</#attempt>
|
73
|
+
|
74
|
+
return <#if doExistMessageForField>text<#else>undefined</#if>;
|
75
|
+
|
76
|
+
</#if>
|
77
|
+
|
78
|
+
<#else>
|
79
|
+
|
80
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
81
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
82
|
+
|
83
|
+
<#local doExistErrorOnUsernameOrPassword = "">
|
84
|
+
|
85
|
+
<#attempt>
|
86
|
+
<#local doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
87
|
+
<#recover>
|
88
|
+
<#local doExistErrorOnUsernameOrPassword = true>
|
89
|
+
</#attempt>
|
90
|
+
|
91
|
+
<#if doExistErrorOnUsernameOrPassword>
|
92
|
+
return text;
|
40
93
|
<#else>
|
41
|
-
|
94
|
+
|
95
|
+
<#local doExistMessageForField = "">
|
96
|
+
|
97
|
+
<#attempt>
|
98
|
+
<#local doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
99
|
+
<#recover>
|
100
|
+
<#local doExistMessageForField = true>
|
101
|
+
</#attempt>
|
102
|
+
|
103
|
+
return <#if doExistMessageForField>text<#else>undefined</#if>;
|
104
|
+
|
42
105
|
</#if>
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
106
|
+
|
107
|
+
<#else>
|
108
|
+
|
109
|
+
<#local doExistMessageForField = "">
|
110
|
+
|
111
|
+
<#attempt>
|
112
|
+
<#local doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
113
|
+
<#recover>
|
114
|
+
<#local doExistMessageForField = true>
|
115
|
+
</#attempt>
|
116
|
+
|
117
|
+
return <#if doExistMessageForField>text<#else>undefined</#if>;
|
118
|
+
|
119
|
+
</#if>
|
120
|
+
|
121
|
+
</#if>
|
122
|
+
|
123
|
+
}
|
124
|
+
</#list>
|
125
|
+
|
126
|
+
throw new Error("There is no " + fieldName + " field. See: https://docs.keycloakify.dev/build-options#keycloakify.customuserattributes");
|
49
127
|
},
|
50
128
|
"existsError": function (fieldName) {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
<#list fieldNames as fieldName>
|
55
|
-
if(fieldName === "${fieldName}" ){
|
56
|
-
<#attempt>
|
57
|
-
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
58
|
-
return <#if messagesPerField.existsError('username', 'password')>true<#else>false</#if>;
|
59
|
-
<#else>
|
60
|
-
return <#if messagesPerField.existsError('${fieldName}')>true<#else>false</#if>;
|
61
|
-
</#if>
|
62
|
-
<#recover>
|
63
|
-
</#attempt>
|
64
|
-
}
|
65
|
-
</#list>
|
66
|
-
throw new Error("There is no " + fieldName + " field");
|
129
|
+
|
130
|
+
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
131
|
+
throw new Error("You're not supposed to use messagesPerField.printIfExists in this page");
|
67
132
|
</#if>
|
133
|
+
|
134
|
+
<#list fieldNames as fieldName>
|
135
|
+
if(fieldName === "${fieldName}" ){
|
136
|
+
|
137
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/359 Compat with Keycloak prior v12 -->
|
138
|
+
<#if !messagesPerField.existsError??>
|
139
|
+
|
140
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
141
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
142
|
+
|
143
|
+
<#local doExistMessageForUsernameOrPassword = "">
|
144
|
+
|
145
|
+
<#attempt>
|
146
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('username')>
|
147
|
+
<#recover>
|
148
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
149
|
+
</#attempt>
|
150
|
+
|
151
|
+
<#if !doExistMessageForUsernameOrPassword>
|
152
|
+
<#attempt>
|
153
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('password')>
|
154
|
+
<#recover>
|
155
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
156
|
+
</#attempt>
|
157
|
+
</#if>
|
158
|
+
|
159
|
+
return <#if doExistMessageForUsernameOrPassword>true<#else>false</#if>;
|
160
|
+
|
161
|
+
<#else>
|
162
|
+
|
163
|
+
<#local doExistMessageForField = "">
|
164
|
+
|
165
|
+
<#attempt>
|
166
|
+
<#local doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
167
|
+
<#recover>
|
168
|
+
<#local doExistMessageForField = true>
|
169
|
+
</#attempt>
|
170
|
+
|
171
|
+
return <#if doExistMessageForField>true<#else>false</#if>;
|
172
|
+
|
173
|
+
</#if>
|
174
|
+
|
175
|
+
<#else>
|
176
|
+
|
177
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
178
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
179
|
+
|
180
|
+
<#local doExistErrorOnUsernameOrPassword = "">
|
181
|
+
|
182
|
+
<#attempt>
|
183
|
+
<#local doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
184
|
+
<#recover>
|
185
|
+
<#local doExistErrorOnUsernameOrPassword = true>
|
186
|
+
</#attempt>
|
187
|
+
|
188
|
+
return <#if doExistErrorOnUsernameOrPassword>true<#else>false</#if>;
|
189
|
+
|
190
|
+
<#else>
|
191
|
+
|
192
|
+
<#local doExistErrorMessageForField = "">
|
193
|
+
|
194
|
+
<#attempt>
|
195
|
+
<#local doExistErrorMessageForField = messagesPerField.existsError('${fieldName}')>
|
196
|
+
<#recover>
|
197
|
+
<#local doExistErrorMessageForField = true>
|
198
|
+
</#attempt>
|
199
|
+
|
200
|
+
return <#if doExistErrorMessageForField>true<#else>false</#if>;
|
201
|
+
|
202
|
+
</#if>
|
203
|
+
|
204
|
+
</#if>
|
205
|
+
|
206
|
+
}
|
207
|
+
</#list>
|
208
|
+
|
209
|
+
throw new Error("There is no " + fieldName + " field. See: https://docs.keycloakify.dev/build-options#keycloakify.customuserattributes");
|
210
|
+
|
68
211
|
},
|
69
212
|
"get": function (fieldName) {
|
70
|
-
|
71
|
-
|
72
|
-
<#
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
213
|
+
|
214
|
+
|
215
|
+
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
216
|
+
throw new Error("You're not supposed to use messagesPerField.get in this page");
|
217
|
+
</#if>
|
218
|
+
|
219
|
+
<#list fieldNames as fieldName>
|
220
|
+
if(fieldName === "${fieldName}" ){
|
221
|
+
|
222
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/359 Compat with Keycloak prior v12 -->
|
223
|
+
<#if !messagesPerField.existsError??>
|
224
|
+
|
225
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
226
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
227
|
+
|
228
|
+
<#local doExistMessageForUsernameOrPassword = "">
|
229
|
+
|
230
|
+
<#attempt>
|
231
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('username')>
|
232
|
+
<#recover>
|
233
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
234
|
+
</#attempt>
|
235
|
+
|
236
|
+
<#if !doExistMessageForUsernameOrPassword>
|
237
|
+
<#attempt>
|
238
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('password')>
|
239
|
+
<#recover>
|
240
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
241
|
+
</#attempt>
|
242
|
+
</#if>
|
243
|
+
|
244
|
+
<#if !doExistMessageForUsernameOrPassword>
|
245
|
+
return "";
|
80
246
|
<#else>
|
81
|
-
<#
|
247
|
+
<#attempt>
|
248
|
+
return "${kcSanitize(msg('invalidUserMessage'))?no_esc}";
|
249
|
+
<#recover>
|
250
|
+
return "Invalid username or password.";
|
251
|
+
</#attempt>
|
252
|
+
</#if>
|
253
|
+
|
254
|
+
<#else>
|
255
|
+
|
256
|
+
<#attempt>
|
257
|
+
return "${messagesPerField.get('${fieldName}')?no_esc}";
|
258
|
+
<#recover>
|
259
|
+
return "invalid field";
|
260
|
+
</#attempt>
|
261
|
+
|
262
|
+
</#if>
|
263
|
+
|
264
|
+
<#else>
|
265
|
+
|
266
|
+
// CONITNUE HERE!!!!!
|
267
|
+
|
268
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
269
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
270
|
+
|
271
|
+
<#local doExistErrorOnUsernameOrPassword = "">
|
272
|
+
|
273
|
+
<#attempt>
|
274
|
+
<#local doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
275
|
+
<#recover>
|
276
|
+
<#local doExistErrorOnUsernameOrPassword = true>
|
277
|
+
</#attempt>
|
278
|
+
|
279
|
+
<#if doExistErrorOnUsernameOrPassword>
|
280
|
+
|
281
|
+
<#attempt>
|
282
|
+
return "${kcSanitize(msg('invalidUserMessage'))?no_esc}";
|
283
|
+
<#recover>
|
284
|
+
return "Invalid username or password.";
|
285
|
+
</#attempt>
|
286
|
+
|
287
|
+
<#else>
|
288
|
+
|
289
|
+
<#attempt>
|
82
290
|
return "${messagesPerField.get('${fieldName}')?no_esc}";
|
83
|
-
|
291
|
+
<#recover>
|
292
|
+
return "";
|
293
|
+
</#attempt>
|
294
|
+
|
84
295
|
</#if>
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
296
|
+
|
297
|
+
<#else>
|
298
|
+
|
299
|
+
<#attempt>
|
300
|
+
return "${messagesPerField.get('${fieldName}')?no_esc}";
|
301
|
+
<#recover>
|
302
|
+
return "invalid field";
|
303
|
+
</#attempt>
|
304
|
+
|
305
|
+
</#if>
|
306
|
+
|
307
|
+
</#if>
|
308
|
+
|
309
|
+
}
|
310
|
+
</#list>
|
311
|
+
|
312
|
+
throw new Error("There is no " + fieldName + " field. See: https://docs.keycloakify.dev/build-options#keycloakify.customuserattributes");
|
313
|
+
|
91
314
|
},
|
92
315
|
"exists": function (fieldName) {
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
<#list fieldNames as fieldName>
|
97
|
-
if(fieldName === "${fieldName}" ){
|
98
|
-
<#attempt>
|
99
|
-
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
100
|
-
return <#if messagesPerField.exists('username') || messagesPerField.exists('password')>true<#else>false</#if>;
|
101
|
-
<#else>
|
102
|
-
return <#if messagesPerField.exists('${fieldName}')>true<#else>false</#if>;
|
103
|
-
</#if>
|
104
|
-
<#recover>
|
105
|
-
</#attempt>
|
106
|
-
}
|
107
|
-
</#list>
|
108
|
-
throw new Error("There is no " + fieldName + " field");
|
316
|
+
|
317
|
+
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
318
|
+
throw new Error("You're not supposed to use messagesPerField.exists in this page");
|
109
319
|
</#if>
|
320
|
+
|
321
|
+
<#list fieldNames as fieldName>
|
322
|
+
if(fieldName === "${fieldName}" ){
|
323
|
+
|
324
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/359 Compat with Keycloak prior v12 -->
|
325
|
+
<#if !messagesPerField.existsError??>
|
326
|
+
|
327
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
328
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
329
|
+
|
330
|
+
<#local doExistMessageForUsernameOrPassword = "">
|
331
|
+
|
332
|
+
<#attempt>
|
333
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('username')>
|
334
|
+
<#recover>
|
335
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
336
|
+
</#attempt>
|
337
|
+
|
338
|
+
<#if !doExistMessageForUsernameOrPassword>
|
339
|
+
<#attempt>
|
340
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('password')>
|
341
|
+
<#recover>
|
342
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
343
|
+
</#attempt>
|
344
|
+
</#if>
|
345
|
+
|
346
|
+
return <#if doExistMessageForUsernameOrPassword>true<#else>false</#if>;
|
347
|
+
|
348
|
+
<#else>
|
349
|
+
|
350
|
+
<#local doExistMessageForField = "">
|
351
|
+
|
352
|
+
<#attempt>
|
353
|
+
<#local doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
354
|
+
<#recover>
|
355
|
+
<#local doExistMessageForField = true>
|
356
|
+
</#attempt>
|
357
|
+
|
358
|
+
return <#if doExistMessageForField>true<#else>false</#if>;
|
359
|
+
|
360
|
+
</#if>
|
361
|
+
|
362
|
+
<#else>
|
363
|
+
|
364
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
365
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
366
|
+
|
367
|
+
<#local doExistErrorOnUsernameOrPassword = "">
|
368
|
+
|
369
|
+
<#attempt>
|
370
|
+
<#local doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
371
|
+
<#recover>
|
372
|
+
<#local doExistErrorOnUsernameOrPassword = true>
|
373
|
+
</#attempt>
|
374
|
+
|
375
|
+
return <#if doExistErrorOnUsernameOrPassword>true<#else>false</#if>;
|
376
|
+
|
377
|
+
<#else>
|
378
|
+
|
379
|
+
<#local doExistErrorMessageForField = "">
|
380
|
+
|
381
|
+
<#attempt>
|
382
|
+
<#local doExistErrorMessageForField = messagesPerField.exists('${fieldName}')>
|
383
|
+
<#recover>
|
384
|
+
<#local doExistErrorMessageForField = true>
|
385
|
+
</#attempt>
|
386
|
+
|
387
|
+
return <#if doExistErrorMessageForField>true<#else>false</#if>;
|
388
|
+
|
389
|
+
</#if>
|
390
|
+
|
391
|
+
</#if>
|
392
|
+
|
393
|
+
}
|
394
|
+
</#list>
|
395
|
+
|
396
|
+
throw new Error("There is no " + fieldName + " field. See: https://docs.keycloakify.dev/build-options#keycloakify.customuserattributes");
|
397
|
+
|
110
398
|
}
|
111
399
|
};
|
112
400
|
|
@@ -51,9 +51,34 @@ export declare namespace KcContext {
|
|
51
51
|
};
|
52
52
|
isAppInitiatedAction: boolean;
|
53
53
|
messagesPerField: {
|
54
|
-
|
54
|
+
/**
|
55
|
+
* Return text if message for given field exists. Useful eg. to add css styles for fields with message.
|
56
|
+
*
|
57
|
+
* @param fieldName to check for
|
58
|
+
* @param text to return
|
59
|
+
* @return text if message exists for given field, else undefined
|
60
|
+
*/
|
61
|
+
printIfExists: <T extends string>(fieldName: string, text: T) => T | undefined;
|
62
|
+
/**
|
63
|
+
* Check if exists error message for given fields
|
64
|
+
*
|
65
|
+
* @param fields
|
66
|
+
* @return boolean
|
67
|
+
*/
|
55
68
|
existsError: (fieldName: string) => boolean;
|
69
|
+
/**
|
70
|
+
* Get message for given field.
|
71
|
+
*
|
72
|
+
* @param fieldName
|
73
|
+
* @return message text or empty string
|
74
|
+
*/
|
56
75
|
get: (fieldName: string) => string;
|
76
|
+
/**
|
77
|
+
* Check if message for given field exists
|
78
|
+
*
|
79
|
+
* @param field
|
80
|
+
* @return boolean
|
81
|
+
*/
|
57
82
|
exists: (fieldName: string) => boolean;
|
58
83
|
};
|
59
84
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KcContext.js","sourceRoot":"","sources":["../../src/login/kcContext/KcContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"KcContext.js","sourceRoot":"","sources":["../../src/login/kcContext/KcContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAskBtC;IAOI,MAAM,EAA4B,CAAC;IACnC,MAAM,EAAiC,CAAC;CAC3C;AAED,MAAM,EAA2D,CAAC"}
|
package/package.json
CHANGED
@@ -52,9 +52,34 @@ export declare namespace KcContext {
|
|
52
52
|
name: string; // Client id
|
53
53
|
};
|
54
54
|
messagesPerField: {
|
55
|
-
|
55
|
+
/**
|
56
|
+
* Return text if message for given field exists. Useful eg. to add css styles for fields with message.
|
57
|
+
*
|
58
|
+
* @param fieldName to check for
|
59
|
+
* @param text to return
|
60
|
+
* @return text if message exists for given field, else undefined
|
61
|
+
*/
|
62
|
+
printIfExists: <T extends string>(fieldName: string, text: T) => T | undefined;
|
63
|
+
/**
|
64
|
+
* Check if exists error message for given fields
|
65
|
+
*
|
66
|
+
* @param fields
|
67
|
+
* @return boolean
|
68
|
+
*/
|
56
69
|
existsError: (fieldName: string) => boolean;
|
70
|
+
/**
|
71
|
+
* Get message for given field.
|
72
|
+
*
|
73
|
+
* @param fieldName
|
74
|
+
* @return message text or empty string
|
75
|
+
*/
|
57
76
|
get: (fieldName: string) => string;
|
77
|
+
/**
|
78
|
+
* Check if message for given field exists
|
79
|
+
*
|
80
|
+
* @param field
|
81
|
+
* @return boolean
|
82
|
+
*/
|
58
83
|
exists: (fieldName: string) => boolean;
|
59
84
|
};
|
60
85
|
account: {
|
@@ -28,85 +28,373 @@
|
|
28
28
|
<#recover>
|
29
29
|
</#attempt>
|
30
30
|
|
31
|
-
"printIfExists": function (fieldName,
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
"printIfExists": function (fieldName, text) {
|
32
|
+
|
33
|
+
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
34
|
+
throw new Error("You're not supposed to use messagesPerField.printIfExists in this page");
|
35
|
+
</#if>
|
36
|
+
|
37
|
+
<#list fieldNames as fieldName>
|
38
|
+
if(fieldName === "${fieldName}" ){
|
39
|
+
|
40
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/359 Compat with Keycloak prior v12 -->
|
41
|
+
<#if !messagesPerField.existsError??>
|
42
|
+
|
43
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
44
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
45
|
+
|
46
|
+
<#local doExistMessageForUsernameOrPassword = "">
|
47
|
+
|
48
|
+
<#attempt>
|
49
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('username')>
|
50
|
+
<#recover>
|
51
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
52
|
+
</#attempt>
|
53
|
+
|
54
|
+
<#if !doExists>
|
55
|
+
<#attempt>
|
56
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('password')>
|
57
|
+
<#recover>
|
58
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
59
|
+
</#attempt>
|
60
|
+
</#if>
|
61
|
+
|
62
|
+
return <#if doExistMessageForUsernameOrPassword>text<#else>undefined</#if>;
|
63
|
+
|
64
|
+
<#else>
|
65
|
+
|
66
|
+
<#local doExistMessageForField = "">
|
67
|
+
|
68
|
+
<#attempt>
|
69
|
+
<#local doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
70
|
+
<#recover>
|
71
|
+
<#local doExistMessageForField = true>
|
72
|
+
</#attempt>
|
73
|
+
|
74
|
+
return <#if doExistMessageForField>text<#else>undefined</#if>;
|
75
|
+
|
76
|
+
</#if>
|
77
|
+
|
78
|
+
<#else>
|
79
|
+
|
80
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
81
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
82
|
+
|
83
|
+
<#local doExistErrorOnUsernameOrPassword = "">
|
84
|
+
|
85
|
+
<#attempt>
|
86
|
+
<#local doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
87
|
+
<#recover>
|
88
|
+
<#local doExistErrorOnUsernameOrPassword = true>
|
89
|
+
</#attempt>
|
90
|
+
|
91
|
+
<#if doExistErrorOnUsernameOrPassword>
|
92
|
+
return text;
|
40
93
|
<#else>
|
41
|
-
|
94
|
+
|
95
|
+
<#local doExistMessageForField = "">
|
96
|
+
|
97
|
+
<#attempt>
|
98
|
+
<#local doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
99
|
+
<#recover>
|
100
|
+
<#local doExistMessageForField = true>
|
101
|
+
</#attempt>
|
102
|
+
|
103
|
+
return <#if doExistMessageForField>text<#else>undefined</#if>;
|
104
|
+
|
42
105
|
</#if>
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
106
|
+
|
107
|
+
<#else>
|
108
|
+
|
109
|
+
<#local doExistMessageForField = "">
|
110
|
+
|
111
|
+
<#attempt>
|
112
|
+
<#local doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
113
|
+
<#recover>
|
114
|
+
<#local doExistMessageForField = true>
|
115
|
+
</#attempt>
|
116
|
+
|
117
|
+
return <#if doExistMessageForField>text<#else>undefined</#if>;
|
118
|
+
|
119
|
+
</#if>
|
120
|
+
|
121
|
+
</#if>
|
122
|
+
|
123
|
+
}
|
124
|
+
</#list>
|
125
|
+
|
126
|
+
throw new Error("There is no " + fieldName + " field. See: https://docs.keycloakify.dev/build-options#keycloakify.customuserattributes");
|
49
127
|
},
|
50
128
|
"existsError": function (fieldName) {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
<#list fieldNames as fieldName>
|
55
|
-
if(fieldName === "${fieldName}" ){
|
56
|
-
<#attempt>
|
57
|
-
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
58
|
-
return <#if messagesPerField.existsError('username', 'password')>true<#else>false</#if>;
|
59
|
-
<#else>
|
60
|
-
return <#if messagesPerField.existsError('${fieldName}')>true<#else>false</#if>;
|
61
|
-
</#if>
|
62
|
-
<#recover>
|
63
|
-
</#attempt>
|
64
|
-
}
|
65
|
-
</#list>
|
66
|
-
throw new Error("There is no " + fieldName + " field");
|
129
|
+
|
130
|
+
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
131
|
+
throw new Error("You're not supposed to use messagesPerField.printIfExists in this page");
|
67
132
|
</#if>
|
133
|
+
|
134
|
+
<#list fieldNames as fieldName>
|
135
|
+
if(fieldName === "${fieldName}" ){
|
136
|
+
|
137
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/359 Compat with Keycloak prior v12 -->
|
138
|
+
<#if !messagesPerField.existsError??>
|
139
|
+
|
140
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
141
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
142
|
+
|
143
|
+
<#local doExistMessageForUsernameOrPassword = "">
|
144
|
+
|
145
|
+
<#attempt>
|
146
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('username')>
|
147
|
+
<#recover>
|
148
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
149
|
+
</#attempt>
|
150
|
+
|
151
|
+
<#if !doExistMessageForUsernameOrPassword>
|
152
|
+
<#attempt>
|
153
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('password')>
|
154
|
+
<#recover>
|
155
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
156
|
+
</#attempt>
|
157
|
+
</#if>
|
158
|
+
|
159
|
+
return <#if doExistMessageForUsernameOrPassword>true<#else>false</#if>;
|
160
|
+
|
161
|
+
<#else>
|
162
|
+
|
163
|
+
<#local doExistMessageForField = "">
|
164
|
+
|
165
|
+
<#attempt>
|
166
|
+
<#local doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
167
|
+
<#recover>
|
168
|
+
<#local doExistMessageForField = true>
|
169
|
+
</#attempt>
|
170
|
+
|
171
|
+
return <#if doExistMessageForField>true<#else>false</#if>;
|
172
|
+
|
173
|
+
</#if>
|
174
|
+
|
175
|
+
<#else>
|
176
|
+
|
177
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
178
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
179
|
+
|
180
|
+
<#local doExistErrorOnUsernameOrPassword = "">
|
181
|
+
|
182
|
+
<#attempt>
|
183
|
+
<#local doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
184
|
+
<#recover>
|
185
|
+
<#local doExistErrorOnUsernameOrPassword = true>
|
186
|
+
</#attempt>
|
187
|
+
|
188
|
+
return <#if doExistErrorOnUsernameOrPassword>true<#else>false</#if>;
|
189
|
+
|
190
|
+
<#else>
|
191
|
+
|
192
|
+
<#local doExistErrorMessageForField = "">
|
193
|
+
|
194
|
+
<#attempt>
|
195
|
+
<#local doExistErrorMessageForField = messagesPerField.existsError('${fieldName}')>
|
196
|
+
<#recover>
|
197
|
+
<#local doExistErrorMessageForField = true>
|
198
|
+
</#attempt>
|
199
|
+
|
200
|
+
return <#if doExistErrorMessageForField>true<#else>false</#if>;
|
201
|
+
|
202
|
+
</#if>
|
203
|
+
|
204
|
+
</#if>
|
205
|
+
|
206
|
+
}
|
207
|
+
</#list>
|
208
|
+
|
209
|
+
throw new Error("There is no " + fieldName + " field. See: https://docs.keycloakify.dev/build-options#keycloakify.customuserattributes");
|
210
|
+
|
68
211
|
},
|
69
212
|
"get": function (fieldName) {
|
70
|
-
|
71
|
-
|
72
|
-
<#
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
213
|
+
|
214
|
+
|
215
|
+
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
216
|
+
throw new Error("You're not supposed to use messagesPerField.get in this page");
|
217
|
+
</#if>
|
218
|
+
|
219
|
+
<#list fieldNames as fieldName>
|
220
|
+
if(fieldName === "${fieldName}" ){
|
221
|
+
|
222
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/359 Compat with Keycloak prior v12 -->
|
223
|
+
<#if !messagesPerField.existsError??>
|
224
|
+
|
225
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
226
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
227
|
+
|
228
|
+
<#local doExistMessageForUsernameOrPassword = "">
|
229
|
+
|
230
|
+
<#attempt>
|
231
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('username')>
|
232
|
+
<#recover>
|
233
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
234
|
+
</#attempt>
|
235
|
+
|
236
|
+
<#if !doExistMessageForUsernameOrPassword>
|
237
|
+
<#attempt>
|
238
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('password')>
|
239
|
+
<#recover>
|
240
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
241
|
+
</#attempt>
|
242
|
+
</#if>
|
243
|
+
|
244
|
+
<#if !doExistMessageForUsernameOrPassword>
|
245
|
+
return "";
|
80
246
|
<#else>
|
81
|
-
<#
|
247
|
+
<#attempt>
|
248
|
+
return "${kcSanitize(msg('invalidUserMessage'))?no_esc}";
|
249
|
+
<#recover>
|
250
|
+
return "Invalid username or password.";
|
251
|
+
</#attempt>
|
252
|
+
</#if>
|
253
|
+
|
254
|
+
<#else>
|
255
|
+
|
256
|
+
<#attempt>
|
257
|
+
return "${messagesPerField.get('${fieldName}')?no_esc}";
|
258
|
+
<#recover>
|
259
|
+
return "invalid field";
|
260
|
+
</#attempt>
|
261
|
+
|
262
|
+
</#if>
|
263
|
+
|
264
|
+
<#else>
|
265
|
+
|
266
|
+
// CONITNUE HERE!!!!!
|
267
|
+
|
268
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
269
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
270
|
+
|
271
|
+
<#local doExistErrorOnUsernameOrPassword = "">
|
272
|
+
|
273
|
+
<#attempt>
|
274
|
+
<#local doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
275
|
+
<#recover>
|
276
|
+
<#local doExistErrorOnUsernameOrPassword = true>
|
277
|
+
</#attempt>
|
278
|
+
|
279
|
+
<#if doExistErrorOnUsernameOrPassword>
|
280
|
+
|
281
|
+
<#attempt>
|
282
|
+
return "${kcSanitize(msg('invalidUserMessage'))?no_esc}";
|
283
|
+
<#recover>
|
284
|
+
return "Invalid username or password.";
|
285
|
+
</#attempt>
|
286
|
+
|
287
|
+
<#else>
|
288
|
+
|
289
|
+
<#attempt>
|
82
290
|
return "${messagesPerField.get('${fieldName}')?no_esc}";
|
83
|
-
|
291
|
+
<#recover>
|
292
|
+
return "";
|
293
|
+
</#attempt>
|
294
|
+
|
84
295
|
</#if>
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
296
|
+
|
297
|
+
<#else>
|
298
|
+
|
299
|
+
<#attempt>
|
300
|
+
return "${messagesPerField.get('${fieldName}')?no_esc}";
|
301
|
+
<#recover>
|
302
|
+
return "invalid field";
|
303
|
+
</#attempt>
|
304
|
+
|
305
|
+
</#if>
|
306
|
+
|
307
|
+
</#if>
|
308
|
+
|
309
|
+
}
|
310
|
+
</#list>
|
311
|
+
|
312
|
+
throw new Error("There is no " + fieldName + " field. See: https://docs.keycloakify.dev/build-options#keycloakify.customuserattributes");
|
313
|
+
|
91
314
|
},
|
92
315
|
"exists": function (fieldName) {
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
<#list fieldNames as fieldName>
|
97
|
-
if(fieldName === "${fieldName}" ){
|
98
|
-
<#attempt>
|
99
|
-
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
100
|
-
return <#if messagesPerField.exists('username') || messagesPerField.exists('password')>true<#else>false</#if>;
|
101
|
-
<#else>
|
102
|
-
return <#if messagesPerField.exists('${fieldName}')>true<#else>false</#if>;
|
103
|
-
</#if>
|
104
|
-
<#recover>
|
105
|
-
</#attempt>
|
106
|
-
}
|
107
|
-
</#list>
|
108
|
-
throw new Error("There is no " + fieldName + " field");
|
316
|
+
|
317
|
+
<#if !messagesPerField?? || !(messagesPerField?is_hash)>
|
318
|
+
throw new Error("You're not supposed to use messagesPerField.exists in this page");
|
109
319
|
</#if>
|
320
|
+
|
321
|
+
<#list fieldNames as fieldName>
|
322
|
+
if(fieldName === "${fieldName}" ){
|
323
|
+
|
324
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/359 Compat with Keycloak prior v12 -->
|
325
|
+
<#if !messagesPerField.existsError??>
|
326
|
+
|
327
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
328
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
329
|
+
|
330
|
+
<#local doExistMessageForUsernameOrPassword = "">
|
331
|
+
|
332
|
+
<#attempt>
|
333
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('username')>
|
334
|
+
<#recover>
|
335
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
336
|
+
</#attempt>
|
337
|
+
|
338
|
+
<#if !doExistMessageForUsernameOrPassword>
|
339
|
+
<#attempt>
|
340
|
+
<#local doExistMessageForUsernameOrPassword = messagesPerField.exists('password')>
|
341
|
+
<#recover>
|
342
|
+
<#local doExistMessageForUsernameOrPassword = true>
|
343
|
+
</#attempt>
|
344
|
+
</#if>
|
345
|
+
|
346
|
+
return <#if doExistMessageForUsernameOrPassword>true<#else>false</#if>;
|
347
|
+
|
348
|
+
<#else>
|
349
|
+
|
350
|
+
<#local doExistMessageForField = "">
|
351
|
+
|
352
|
+
<#attempt>
|
353
|
+
<#local doExistMessageForField = messagesPerField.exists('${fieldName}')>
|
354
|
+
<#recover>
|
355
|
+
<#local doExistMessageForField = true>
|
356
|
+
</#attempt>
|
357
|
+
|
358
|
+
return <#if doExistMessageForField>true<#else>false</#if>;
|
359
|
+
|
360
|
+
</#if>
|
361
|
+
|
362
|
+
<#else>
|
363
|
+
|
364
|
+
<#-- https://github.com/keycloakify/keycloakify/pull/218 -->
|
365
|
+
<#if '${fieldName}' == 'username' || '${fieldName}' == 'password'>
|
366
|
+
|
367
|
+
<#local doExistErrorOnUsernameOrPassword = "">
|
368
|
+
|
369
|
+
<#attempt>
|
370
|
+
<#local doExistErrorOnUsernameOrPassword = messagesPerField.existsError('username', 'password')>
|
371
|
+
<#recover>
|
372
|
+
<#local doExistErrorOnUsernameOrPassword = true>
|
373
|
+
</#attempt>
|
374
|
+
|
375
|
+
return <#if doExistErrorOnUsernameOrPassword>true<#else>false</#if>;
|
376
|
+
|
377
|
+
<#else>
|
378
|
+
|
379
|
+
<#local doExistErrorMessageForField = "">
|
380
|
+
|
381
|
+
<#attempt>
|
382
|
+
<#local doExistErrorMessageForField = messagesPerField.exists('${fieldName}')>
|
383
|
+
<#recover>
|
384
|
+
<#local doExistErrorMessageForField = true>
|
385
|
+
</#attempt>
|
386
|
+
|
387
|
+
return <#if doExistErrorMessageForField>true<#else>false</#if>;
|
388
|
+
|
389
|
+
</#if>
|
390
|
+
|
391
|
+
</#if>
|
392
|
+
|
393
|
+
}
|
394
|
+
</#list>
|
395
|
+
|
396
|
+
throw new Error("There is no " + fieldName + " field. See: https://docs.keycloakify.dev/build-options#keycloakify.customuserattributes");
|
397
|
+
|
110
398
|
}
|
111
399
|
};
|
112
400
|
|
@@ -81,9 +81,34 @@ export declare namespace KcContext {
|
|
81
81
|
};
|
82
82
|
isAppInitiatedAction: boolean;
|
83
83
|
messagesPerField: {
|
84
|
-
|
84
|
+
/**
|
85
|
+
* Return text if message for given field exists. Useful eg. to add css styles for fields with message.
|
86
|
+
*
|
87
|
+
* @param fieldName to check for
|
88
|
+
* @param text to return
|
89
|
+
* @return text if message exists for given field, else undefined
|
90
|
+
*/
|
91
|
+
printIfExists: <T extends string>(fieldName: string, text: T) => T | undefined;
|
92
|
+
/**
|
93
|
+
* Check if exists error message for given fields
|
94
|
+
*
|
95
|
+
* @param fields
|
96
|
+
* @return boolean
|
97
|
+
*/
|
85
98
|
existsError: (fieldName: string) => boolean;
|
99
|
+
/**
|
100
|
+
* Get message for given field.
|
101
|
+
*
|
102
|
+
* @param fieldName
|
103
|
+
* @return message text or empty string
|
104
|
+
*/
|
86
105
|
get: (fieldName: string) => string;
|
106
|
+
/**
|
107
|
+
* Check if message for given field exists
|
108
|
+
*
|
109
|
+
* @param field
|
110
|
+
* @return boolean
|
111
|
+
*/
|
87
112
|
exists: (fieldName: string) => boolean;
|
88
113
|
};
|
89
114
|
};
|