Skip to content

Commit 2bac83c

Browse files
Francesco MautoAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2024_02_x/DSC-1786 (pull request DSpace#4610)
[DSC-1786] fix: i18n missing labels Approved-by: Andrea Barbasso
2 parents 33604d3 + 5be31a6 commit 2bac83c

6 files changed

Lines changed: 46 additions & 9 deletions

File tree

src/app/register-email-form/register-email-form.component.spec.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import {
2424
import { RestResponse } from '../core/cache/response.models';
2525
import { ConfigurationDataService } from '../core/data/configuration-data.service';
2626
import { EpersonRegistrationService } from '../core/data/eperson-registration.service';
27-
import { GoogleRecaptchaService } from '../core/google-recaptcha/google-recaptcha.service';
27+
import {
28+
CAPTCHA_REGISTRATION_NAME,
29+
GoogleRecaptchaService,
30+
} from '../core/google-recaptcha/google-recaptcha.service';
2831
import { CookieService } from '../core/services/cookie.service';
2932
import { ConfigurationProperty } from '../core/shared/configuration-property.model';
3033
import { AlertComponent } from '../shared/alert/alert.component';
@@ -209,5 +212,15 @@ describe('RegisterEmailFormComponent', () => {
209212
expect(notificationsService.error).toHaveBeenCalled();
210213
expect(router.navigate).not.toHaveBeenCalled();
211214
}));
215+
it('isRecaptchaCookieAccepted should return true when registration recaptcha cookie is accepted', () => {
216+
const cookieService = TestBed.inject(CookieService) as unknown as CookieServiceMock;
217+
cookieService.set('klaro-anonymous', { [CAPTCHA_REGISTRATION_NAME]: true });
218+
expect(comp.isRecaptchaCookieAccepted()).toBeTrue();
219+
});
220+
it('isRecaptchaCookieAccepted should return false when registration recaptcha cookie is not accepted', () => {
221+
const cookieService = TestBed.inject(CookieService) as unknown as CookieServiceMock;
222+
cookieService.set('klaro-anonymous', { [CAPTCHA_REGISTRATION_NAME]: false });
223+
expect(comp.isRecaptchaCookieAccepted()).toBeFalse();
224+
});
212225
});
213226
});

src/app/register-email-form/register-email-form.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { ConfigurationDataService } from '../core/data/configuration-data.servic
4242
import { EpersonRegistrationService } from '../core/data/eperson-registration.service';
4343
import { RemoteData } from '../core/data/remote-data';
4444
import {
45-
CAPTCHA_FEEDBACK_NAME,
45+
CAPTCHA_REGISTRATION_NAME,
4646
GoogleRecaptchaService,
4747
} from '../core/google-recaptcha/google-recaptcha.service';
4848
import { CookieService } from '../core/services/cookie.service';
@@ -247,7 +247,7 @@ export class RegisterEmailFormComponent implements OnDestroy, OnInit {
247247
*/
248248
isRecaptchaCookieAccepted(): boolean {
249249
const klaroAnonymousCookie = this.cookieService.get('klaro-anonymous');
250-
return isNotEmpty(klaroAnonymousCookie) ? klaroAnonymousCookie[CAPTCHA_FEEDBACK_NAME] : false;
250+
return isNotEmpty(klaroAnonymousCookie) ? klaroAnonymousCookie[CAPTCHA_REGISTRATION_NAME] : false;
251251
}
252252

253253
/**

src/app/shared/cookies/browser-klaro.service.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ import { AuthService } from '../../core/auth/auth.service';
2929
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
3030
import { EPersonDataService } from '../../core/eperson/eperson-data.service';
3131
import { EPerson } from '../../core/eperson/models/eperson.model';
32-
import { CAPTCHA_FEEDBACK_NAME } from '../../core/google-recaptcha/google-recaptcha.service';
32+
import {
33+
CAPTCHA_FEEDBACK_NAME,
34+
CAPTCHA_REGISTRATION_NAME,
35+
} from '../../core/google-recaptcha/google-recaptcha.service';
3336
import { CookieService } from '../../core/services/cookie.service';
3437
import {
3538
NativeWindowRef,
@@ -79,7 +82,7 @@ const updateDebounce = 300;
7982
/**
8083
* By using this injection token instead of importing directly we can keep Klaro out of the main bundle
8184
*/
82-
const LAZY_KLARO = new InjectionToken<Promise<any>>(
85+
export const LAZY_KLARO = new InjectionToken<Promise<any>>(
8386
'Lazily loaded Klaro',
8487
{
8588
providedIn: 'root',
@@ -209,7 +212,10 @@ export class BrowserKlaroService extends KlaroService {
209212
if (hideGoogleAnalytics) {
210213
servicesToHideArray.push(this.GOOGLE_ANALYTICS_SERVICE_NAME);
211214
}
212-
if (hideRegistrationVerification && hideFeedbackVerification) {
215+
if (hideRegistrationVerification) {
216+
servicesToHideArray.push(CAPTCHA_REGISTRATION_NAME);
217+
}
218+
if (hideFeedbackVerification) {
213219
servicesToHideArray.push(CAPTCHA_FEEDBACK_NAME);
214220
}
215221
if (hideMatomo) {

src/app/shared/cookies/klaro-configuration.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { TOKENITEM } from '../../core/auth/models/auth-token-info.model';
77
import {
88
CAPTCHA_COOKIE,
99
CAPTCHA_FEEDBACK_NAME,
10+
CAPTCHA_REGISTRATION_NAME,
1011
} from '../../core/google-recaptcha/google-recaptcha.service';
1112
import { LANG_COOKIE } from '../../core/locale/locale.service';
1213

@@ -209,7 +210,7 @@ export const klaroConfiguration: any = {
209210
onlyOnce: true,
210211
},
211212
{
212-
name: CAPTCHA_FEEDBACK_NAME,
213+
name: CAPTCHA_REGISTRATION_NAME,
213214
purposes: ['registration-password-recovery'],
214215
required: false,
215216
cookies: [
@@ -219,6 +220,17 @@ export const klaroConfiguration: any = {
219220
onDecline: `window.refreshCaptchaScript?.call()`,
220221
onlyOnce: true,
221222
},
223+
{
224+
name: CAPTCHA_FEEDBACK_NAME,
225+
purposes: ['feedback-form-submission'],
226+
required: false,
227+
cookies: [
228+
CAPTCHA_COOKIE,
229+
],
230+
onAccept: `window.refreshCaptchaScript?.call()`,
231+
onDecline: `window.refreshCaptchaScript?.call()`,
232+
onlyOnce: true,
233+
},
222234
{
223235
name: 'accessibility',
224236
purposes: ['functional'],

src/assets/i18n/en.json5

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,9 @@
20822082

20832083
"cookies.consent.app.title.google-recaptcha-registration": "Google reCaptcha",
20842084

2085-
"cookies.consent.app.description.google-recaptcha": "We use google reCAPTCHA service during registration and password recovery",
2085+
"cookies.consent.app.description.google-recaptcha": "We use google reCAPTCHA service during the send feedback form",
2086+
2087+
"cookies.consent.app.description.google-recaptcha-registration": "We use google reCAPTCHA service during registration and password recovery",
20862088

20872089
"cookies.consent.app.title.matomo": "Matomo",
20882090

src/assets/i18n/it.json5

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3362,7 +3362,11 @@
33623362

33633363

33643364
// "cookies.consent.app.description.google-recaptcha": "We use google reCAPTCHA service during registration and password recovery",
3365-
"cookies.consent.app.description.google-recaptcha": "Utilizziamo il servizio Google reCAPTCHA nelle fasi di registrazione e recupero password",
3365+
"cookies.consent.app.description.google-recaptcha": "Utilizziamo il servizio Google reCAPTCHA nella fase di invio feedback",
3366+
3367+
// "cookies.consent.app.description.google-recaptcha-registration": "We use google reCAPTCHA service during registration and password recovery",
3368+
"cookies.consent.app.description.google-recaptcha-registration": "Utilizziamo il servizio Google reCAPTCHA nelle fasi di registrazione e recupero password",
3369+
33663370

33673371

33683372
// "cookies.consent.app.title.matomo": "Matomo",

0 commit comments

Comments
 (0)