|
|
@ -1,8 +1,8 @@
|
|
|
|
import matrix from 'matrix-js-sdk';
|
|
|
|
/*import matrix from 'matrix-js-sdk';
|
|
|
|
import main from '@/main.js';
|
|
|
|
import main from '@/main.js';
|
|
|
|
// import Vue from 'vue';
|
|
|
|
// import Vue from 'vue';
|
|
|
|
|
|
|
|
|
|
|
|
let client = matrix.createClient({});
|
|
|
|
let client = undefined;
|
|
|
|
let session = {
|
|
|
|
let session = {
|
|
|
|
user: '',
|
|
|
|
user: '',
|
|
|
|
baseUrl: '',
|
|
|
|
baseUrl: '',
|
|
|
@ -44,23 +44,12 @@ export default {
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
session,
|
|
|
|
session,
|
|
|
|
|
|
|
|
client
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
login() {
|
|
|
|
login() {
|
|
|
|
if (session.accessToken !== '') {
|
|
|
|
|
|
|
|
main.methods.error('you are already logged in');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
} if (session.login.user === '') {
|
|
|
|
|
|
|
|
main.methods.error('username is empty');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
} if (session.login.password === '') {
|
|
|
|
|
|
|
|
main.methods.error('password is empty');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
} if (!(session.login.user.includes('@') && session.login.user.includes(':'))) {
|
|
|
|
|
|
|
|
main.methods.error('username is in wrong style');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
client = matrix.createClient({
|
|
|
|
client = matrix.createClient({
|
|
|
|
baseUrl: session.login.baseUrl
|
|
|
|
baseUrl: session.login.baseUrl
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -72,6 +61,7 @@ export default {
|
|
|
|
document.cookie = `accessToken=${response.access_token}`;
|
|
|
|
document.cookie = `accessToken=${response.access_token}`;
|
|
|
|
document.cookie = `userId=${session.login.user}`;
|
|
|
|
document.cookie = `userId=${session.login.user}`;
|
|
|
|
document.cookie = `baseUrl=${session.login.baseUrl}`;
|
|
|
|
document.cookie = `baseUrl=${session.login.baseUrl}`;
|
|
|
|
|
|
|
|
document.cookie = `SameSite=Strict`;
|
|
|
|
document.cookie = `expires=${new Date(Date.now() + 86400 * 10 * 1000)}`;
|
|
|
|
document.cookie = `expires=${new Date(Date.now() + 86400 * 10 * 1000)}`;
|
|
|
|
session = {
|
|
|
|
session = {
|
|
|
|
user: session.login.user,
|
|
|
|
user: session.login.user,
|
|
|
@ -86,12 +76,12 @@ export default {
|
|
|
|
console.log(`login error => ${response.error}`);
|
|
|
|
console.log(`login error => ${response.error}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
window.location.href = '/#/rooms/';
|
|
|
|
window.location.href = '/#/rooms/';
|
|
|
|
window.location.reload();
|
|
|
|
window.location.reload();*/
|
|
|
|
/*client.startClient();
|
|
|
|
/*client.startClient();
|
|
|
|
client.once('sync', (state) => {
|
|
|
|
client.once('sync', (state) => {
|
|
|
|
console.log(state);
|
|
|
|
console.log(state);
|
|
|
|
});*/
|
|
|
|
});*/
|
|
|
|
});
|
|
|
|
/* });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
logout(){
|
|
|
|
logout(){
|
|
|
|
document.cookie = `accessToken=`;
|
|
|
|
document.cookie = `accessToken=`;
|
|
|
@ -124,7 +114,7 @@ function getCookie(key) {
|
|
|
|
return cookie ? cookie.split('=')[1] : false;
|
|
|
|
return cookie ? cookie.split('=')[1] : false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
client.on('event', (event) => {
|
|
|
|
/*client.on('event', (event) => {
|
|
|
|
//console.log(event.getType());
|
|
|
|
//console.log(event.getType());
|
|
|
|
//console.log(event);
|
|
|
|
//console.log(event);
|
|
|
|
if (event.getType() === 'm.room.name') {
|
|
|
|
if (event.getType() === 'm.room.name') {
|
|
|
@ -175,4 +165,4 @@ client.on('Room.timeline', (event, room) => {
|
|
|
|
} else document.getElementById('scrollDown').style.display = 'block';
|
|
|
|
} else document.getElementById('scrollDown').style.display = 'block';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});*/
|
|
|
|