refactor(exam-correct): refactor xsrf token and encryption options

This commit is contained in:
Sarah Vaupel 2020-01-28 18:12:13 +01:00
parent fe28762d1c
commit e7c8b6611b

View File

@ -2,7 +2,6 @@ import { Utility } from '../../core/utility';
import { StorageManager, LOCATION } from '../../lib/storage-manager/storage-manager'; import { StorageManager, LOCATION } from '../../lib/storage-manager/storage-manager';
import { HttpClient } from '../../services/http-client/http-client'; import { HttpClient } from '../../services/http-client/http-client';
import Cookies from 'js-cookie';
import moment from 'moment'; import moment from 'moment';
import './exam-correct.sass'; import './exam-correct.sass';
@ -10,7 +9,6 @@ import './exam-correct.sass';
const EXAM_CORRECT_URL_POST = 'correct'; const EXAM_CORRECT_URL_POST = 'correct';
const EXAM_CORRECT_HEADERS = { const EXAM_CORRECT_HEADERS = {
'X-XSRF-TOKEN': Cookies.get('XSRF-TOKEN'),
'Content-Type': HttpClient.ACCEPT.JSON, 'Content-Type': HttpClient.ACCEPT.JSON,
'Accept': HttpClient.ACCEPT.JSON, 'Accept': HttpClient.ACCEPT.JSON,
}; };
@ -40,7 +38,7 @@ const STATUS = {
}) })
export class ExamCorrect { export class ExamCorrect {
_storageManager = new StorageManager('EXAM_CORRECT', '0.0.0', { location: LOCATION.SESSION, encrypted: true }); _storageManager;
_dateFormat; _dateFormat;
_element; _element;
@ -65,6 +63,9 @@ export class ExamCorrect {
this._element = element; this._element = element;
this._app = app; this._app = app;
this._storageManager = new StorageManager('EXAM_CORRECT', '0.0.0', { location: LOCATION.SESSION, encryption: { tag: 'exam-correct', exam: this._element.getAttribute('uw-exam-correct') } });
this._sendBtn = document.getElementById(EXAM_CORRECT_SEND_BTN_ID); this._sendBtn = document.getElementById(EXAM_CORRECT_SEND_BTN_ID);
this._userInput = document.getElementById(EXAM_CORRECT_USER_INPUT_ID); this._userInput = document.getElementById(EXAM_CORRECT_USER_INPUT_ID);
this._userInputStatus = document.getElementById(EXAM_CORRECT_USER_INPUT_STATUS_ID); this._userInputStatus = document.getElementById(EXAM_CORRECT_USER_INPUT_STATUS_ID);