@aarhus-university/au-lib-react-components 9.18.3 → 9.19.1
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/build/umd/alphabox.js.map +1 -1
- package/build/umd/auAuth.js.map +1 -1
- package/build/umd/databox.js.map +1 -1
- package/build/umd/diagramme.js.map +1 -1
- package/build/umd/flowbox.js.map +1 -1
- package/build/umd/news.js.map +1 -1
- package/build/umd/universe.js +1 -1
- package/build/umd/universe.js.map +1 -1
- package/package.json +1 -1
- package/src/components/profile/AUProfileNameComponent.js +4 -4
- package/src/components/universe/StaffTopComponent.js +2 -2
- package/src/lib/i18n.js +4 -0
- package/src/lib/validation.js +10 -1
package/package.json
CHANGED
|
@@ -8,8 +8,8 @@ import { Link } from 'react-router-dom';
|
|
|
8
8
|
import AUSubmitButtonContainerComponent from '../form/AUSubmitButtonContainerComponent';
|
|
9
9
|
import { useProfileForm } from './AUProfileHooks';
|
|
10
10
|
import { scrollTo } from '../../lib/helpers';
|
|
11
|
-
import { profileLabels } from '../../lib/i18n';
|
|
12
|
-
import { renderValidation, validateForm } from '../../lib/validation';
|
|
11
|
+
import { passwordLabels, profileLabels } from '../../lib/i18n';
|
|
12
|
+
import { renderValidation, validateForm, validateSpecialCharacters } from '../../lib/validation';
|
|
13
13
|
|
|
14
14
|
const AUProfileNameComponent = ({
|
|
15
15
|
lang,
|
|
@@ -46,14 +46,14 @@ const AUProfileNameComponent = ({
|
|
|
46
46
|
const [onCancel] = useProfileForm(saved, history, lang, clear);
|
|
47
47
|
|
|
48
48
|
const validateFirstName = (value, alert = true) => {
|
|
49
|
-
const [valid, messages] = validateForm(lang, value, [validationRules[0]]);
|
|
49
|
+
const [valid, messages] = validateForm(lang, value, [validationRules[0], validateSpecialCharacters(passwordLabels[lang].specialCharacters)]);
|
|
50
50
|
setChosenFirstNames(value);
|
|
51
51
|
setFirstNameValidationMessages(alert ? messages : []);
|
|
52
52
|
setIsFirstNameValid(!hasChosenName || valid);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const validateLastName = (value, alert = true) => {
|
|
56
|
-
const [valid, messages] = validateForm(lang, value, [validationRules[1]]);
|
|
56
|
+
const [valid, messages] = validateForm(lang, value, [validationRules[1], validateSpecialCharacters(passwordLabels[lang].specialCharacters)]);
|
|
57
57
|
setChosenLastName(value);
|
|
58
58
|
setLastNameValidationMessages(alert ? messages : []);
|
|
59
59
|
setIsLastNameValid(!hasChosenName || valid);
|
|
@@ -193,7 +193,7 @@ class StaffTopComponent extends React.Component {
|
|
|
193
193
|
{
|
|
194
194
|
url: `${window.profileApiUri}/${lang}/profile`,
|
|
195
195
|
text: profileLabels[lang].headerContainer,
|
|
196
|
-
},
|
|
196
|
+
},
|
|
197
197
|
{
|
|
198
198
|
url: `${window.profileApiUri}/${lang}/password`,
|
|
199
199
|
text: profileLabels[lang].headerPassword,
|
|
@@ -201,7 +201,7 @@ class StaffTopComponent extends React.Component {
|
|
|
201
201
|
{
|
|
202
202
|
url: `${window.profileApiUri}/${lang}/quick-edit`,
|
|
203
203
|
text: profileLabels[lang].headerPureProfile,
|
|
204
|
-
},
|
|
204
|
+
},
|
|
205
205
|
{
|
|
206
206
|
url: 'https://mithr.au.dk/',
|
|
207
207
|
text: profileLabels[lang].headerVacationAbsence,
|
package/src/lib/i18n.js
CHANGED
|
@@ -161,6 +161,7 @@ const profileLabels = {
|
|
|
161
161
|
profileFor: 'Profilmenu for',
|
|
162
162
|
changeLanguageButton: 'Switch to English',
|
|
163
163
|
headerPureProfile: 'Redigér din hjemmeside',
|
|
164
|
+
specialCharacters: 'Navnet må ikke indeholde specialtegn.',
|
|
164
165
|
},
|
|
165
166
|
en: {
|
|
166
167
|
login: 'Sign in',
|
|
@@ -223,6 +224,7 @@ const profileLabels = {
|
|
|
223
224
|
profileFor: 'Profile menu for',
|
|
224
225
|
changeLanguageButton: 'Skift til dansk',
|
|
225
226
|
headerPureProfile: 'Edit your webpage',
|
|
227
|
+
specialCharacters: 'The name must not contain special characters.',
|
|
226
228
|
},
|
|
227
229
|
};
|
|
228
230
|
|
|
@@ -291,6 +293,7 @@ const passwordLabels = {
|
|
|
291
293
|
supportStaffLink: 'https://medarbejdere.au.dk/administration/it/',
|
|
292
294
|
supportStaffText: 'Support til medarbejdere og andre',
|
|
293
295
|
pwned: 'Adgangskoden kan ikke bruges, da den tidligere har været brugt på andre hjemmesider, som er blevet hacket. Prøv med en anden.',
|
|
296
|
+
specialCharacters: 'Navnet må ikke indeholde specialtegn.',
|
|
294
297
|
},
|
|
295
298
|
en: {
|
|
296
299
|
currentPassword: 'Enter your current password',
|
|
@@ -356,6 +359,7 @@ const passwordLabels = {
|
|
|
356
359
|
supportStaffLink: 'https://medarbejdere.au.dk/en/administration/it/',
|
|
357
360
|
supportStaffText: 'Support for staff and others',
|
|
358
361
|
pwned: 'The password cannot be used because it has been used before on other websites that have been hacked. Please try a different password.',
|
|
362
|
+
specialCharacters: 'The name must not contain special characters.',
|
|
359
363
|
},
|
|
360
364
|
};
|
|
361
365
|
|
package/src/lib/validation.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { passwordLabels } from './i18n';
|
|
3
5
|
|
|
@@ -181,7 +183,7 @@ const validatePassword = async (
|
|
|
181
183
|
|
|
182
184
|
if (newPasswordValid) {
|
|
183
185
|
newPasswordMessages.push(passwordLabels[lang].allRequirements);
|
|
184
|
-
}
|
|
186
|
+
}
|
|
185
187
|
|
|
186
188
|
return {
|
|
187
189
|
newPasswordValid,
|
|
@@ -208,6 +210,12 @@ const isPwned = async (data) => {
|
|
|
208
210
|
return false;
|
|
209
211
|
};
|
|
210
212
|
|
|
213
|
+
const validateSpecialCharacters = (message) => ({
|
|
214
|
+
message,
|
|
215
|
+
// Validates that the string does NOT contain ASCII 33-38, 40-44, 47, 58-64, 91-96, 123-127
|
|
216
|
+
rule: (fieldValue) => !(/[\x21-\x26\x28-\x2C\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/.test(fieldValue)),
|
|
217
|
+
});
|
|
218
|
+
|
|
211
219
|
export {
|
|
212
220
|
emailRegex,
|
|
213
221
|
studentRegistrationNumberRegex,
|
|
@@ -216,4 +224,5 @@ export {
|
|
|
216
224
|
validatePassword,
|
|
217
225
|
validateForm,
|
|
218
226
|
isPwned,
|
|
227
|
+
validateSpecialCharacters,
|
|
219
228
|
};
|