mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-15593] fix authenticated orejime cookie encoding
This commit is contained in:
@@ -56,7 +56,7 @@ before(() => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Pre-agree to all Orejime cookies by setting the orejime-anonymous cookie
|
// Pre-agree to all Orejime cookies by setting the orejime-anonymous cookie
|
||||||
// This just ensures it doesn't get in the way of matching other objects in the page.
|
// This just ensures it doesn't get in the way of matching other objects in the page.
|
||||||
cy.setCookie('orejime-anonymous', '{%22authentication%22:true%2C%22preferences%22:true%2C%22acknowledgement%22:true%2C%22google-analytics%22:true%2C%22google-recaptcha%22:true}');
|
cy.setCookie('orejime-anonymous', '{"authentication":true,"preferences":true,"acknowledgement":true,"google-analytics":true}');
|
||||||
|
|
||||||
// Remove any CSRF cookies saved from prior tests
|
// Remove any CSRF cookies saved from prior tests
|
||||||
cy.clearCookie(DSPACE_XSRF_COOKIE);
|
cy.clearCookie(DSPACE_XSRF_COOKIE);
|
||||||
|
@@ -70,7 +70,7 @@ describe('BrowserOrejimeService', () => {
|
|||||||
configurationDataService = createConfigSuccessSpy(recaptchaValue);
|
configurationDataService = createConfigSuccessSpy(recaptchaValue);
|
||||||
findByPropertyName = configurationDataService.findByPropertyName;
|
findByPropertyName = configurationDataService.findByPropertyName;
|
||||||
cookieService = jasmine.createSpyObj('cookieService', {
|
cookieService = jasmine.createSpyObj('cookieService', {
|
||||||
get: '{%22token_item%22:true%2C%22impersonation%22:true%2C%22redirect%22:true%2C%22language%22:true%2C%22orejime%22:true%2C%22has_agreed_end_user%22:true%2C%22google-analytics%22:true}',
|
get: '{"authentication":true,"preferences":true,"acknowledgement":true,"google-analytics":true}',
|
||||||
set: () => {
|
set: () => {
|
||||||
/* empty */
|
/* empty */
|
||||||
},
|
},
|
||||||
|
@@ -207,7 +207,7 @@ export class BrowserOrejimeService extends OrejimeService {
|
|||||||
*/
|
*/
|
||||||
private initializeUser(user: EPerson) {
|
private initializeUser(user: EPerson) {
|
||||||
this.orejimeConfig.callback = debounce((consent, app) => this.updateSettingsForUsers(user), updateDebounce);
|
this.orejimeConfig.callback = debounce((consent, app) => this.updateSettingsForUsers(user), updateDebounce);
|
||||||
this.orejimeConfig.storageName = this.getStorageName(user.uuid);
|
this.orejimeConfig.cookieName = this.getStorageName(user.uuid);
|
||||||
|
|
||||||
const anonCookie = this.cookieService.get(ANONYMOUS_STORAGE_NAME_OREJIME);
|
const anonCookie = this.cookieService.get(ANONYMOUS_STORAGE_NAME_OREJIME);
|
||||||
if (hasValue(this.getSettingsForUser(user))) {
|
if (hasValue(this.getSettingsForUser(user))) {
|
||||||
|
@@ -44,6 +44,18 @@ export function getOrejimeConfiguration(_window: NativeWindowRef): any {
|
|||||||
*/
|
*/
|
||||||
appElement: 'ds-app',
|
appElement: 'ds-app',
|
||||||
|
|
||||||
|
stringifyCookie: (contents: any) => {
|
||||||
|
return (typeof contents === 'string') ? contents : JSON.stringify(contents);
|
||||||
|
},
|
||||||
|
|
||||||
|
parseCookie: (cookie: string) => {
|
||||||
|
if (typeof cookie === 'string') {
|
||||||
|
cookie = decodeURIComponent(cookie);
|
||||||
|
return JSON.parse(cookie);
|
||||||
|
}
|
||||||
|
return cookie;
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
You can overwrite existing translations and add translations for your app
|
You can overwrite existing translations and add translations for your app
|
||||||
descriptions and purposes. See `src/translations/` for a full list of
|
descriptions and purposes. See `src/translations/` for a full list of
|
||||||
|
Reference in New Issue
Block a user