diff --git a/src/components/newMessage.vue b/src/components/newMessage.vue
index 93a8d6c..7adbd8d 100644
--- a/src/components/newMessage.vue
+++ b/src/components/newMessage.vue
@@ -36,7 +36,7 @@
this.store.setItem(key, obj[key]));
+ }
+}
\ No newline at end of file
diff --git a/src/lib/matrixHandler.js b/src/lib/MatrixHandler.js
similarity index 95%
rename from src/lib/matrixHandler.js
rename to src/lib/MatrixHandler.js
index c277f43..afe4317 100644
--- a/src/lib/matrixHandler.js
+++ b/src/lib/MatrixHandler.js
@@ -48,7 +48,8 @@ export class MatrixHandler {
baseUrl,
accessToken,
userId,
- store: new matrix.MemoryStore(window.localStorage)
+ store: new matrix.MemoryStore(window.localStorage),
+ sessionStore: new matrix.WebStorageSessionStore(window.localStorage)
});
this.user = userId;
this.baseUrl = baseUrl;
diff --git a/src/lib/cookieHandler.js b/src/lib/cookieHandler.js
index fb8bf8e..72f9c23 100644
--- a/src/lib/cookieHandler.js
+++ b/src/lib/cookieHandler.js
@@ -8,11 +8,17 @@ export class cookieHandler {
getCookies(){
return this.cookies;
}
- setCookie(cookies){
+ setCookies(cookies){
Object.keys(cookies).forEach(key => {
this.cookies[key] = cookies[key];
})
}
+ set(key, value){
+ this.cookies[key] = value;
+ }
+ get(key){
+ return this.cookies[key];
+ }
parseCookie(string){
let cookies = {};
string.replace(/ /g, '').split(';').forEach(cookie => {
@@ -24,14 +30,12 @@ export class cookieHandler {
reload(){
if (document.cookie) this.cookies = this.parseCookie(document.cookie);
console.log('cookie loaded')
- console.log(this.cookies);
}
store(){
Object.keys(this.cookies).forEach(key => {
document.cookie = `${key}=${this.cookies[key]}; expires=${this.expires}; SameSite=${this.SameSite}; Secure;`;
});
console.log('cookie stored');
- console.log(this.cookies);
}
toString(cookies = this.cookies){
let string = '';
diff --git a/src/main.js b/src/main.js
index 4883dbf..d0bbe93 100644
--- a/src/main.js
+++ b/src/main.js
@@ -2,17 +2,18 @@ import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App.vue'
import {router} from '@/router'
-import {MatrixHandler} from './lib/matrixHandler.js'
-import {cookieHandler} from './lib/cookieHandler.js';
+import {MatrixHandler} from './lib/MatrixHandler.js'
+import {DataStore} from '@/lib/DataStore';
Vue.config.productionTip = false;
Vue.use(VueRouter);
export let matrix = new MatrixHandler();
-let cookie = new cookieHandler().getCookies();
-if (cookie && cookie.baseUrl && cookie.accessToken && cookie.userId) {
- matrix.tokenLogin(cookie.baseUrl, cookie.accessToken, cookie.userId);
+let store = new DataStore();
+
+if (store.get('baseUrl') && store.get('accessToken') && store.get('userId')) {
+ matrix.tokenLogin(store.get('baseUrl'), store.get('accessToken'), store.get('userId'));
}
new Vue({
diff --git a/src/views/login.vue b/src/views/login.vue
index 065bd7d..f386604 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -22,9 +22,9 @@