|
|
@ -1,7 +1,8 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div id="login">
|
|
|
|
<div class="login">
|
|
|
|
|
|
|
|
<div class="loginBox">
|
|
|
|
<h1 class="title">[chat]</h1>
|
|
|
|
<h1 class="title">[chat]</h1>
|
|
|
|
<form v-if="showLogin" @submit.prevent="login()">
|
|
|
|
<form v-if="showLogin()" @submit.prevent="login()">
|
|
|
|
<input v-model="user" class="input" name="user" type="text" maxlength="30" placeholder="@user:adb.sh"><br>
|
|
|
|
<input v-model="user" class="input" name="user" type="text" maxlength="30" placeholder="@user:adb.sh"><br>
|
|
|
|
<input v-model="password" class="input" name="password" type="password" maxlength="30" placeholder="password"><br>
|
|
|
|
<input v-model="password" class="input" name="password" type="password" maxlength="30" placeholder="password"><br>
|
|
|
|
<input v-model="homeServer" class="input" name="homeserver" maxlength="50" placeholder="https://matrix.org"><br>
|
|
|
|
<input v-model="homeServer" class="input" name="homeserver" maxlength="50" placeholder="https://matrix.org"><br>
|
|
|
@ -14,16 +15,20 @@
|
|
|
|
<textbtn @click.native="logout()" text="logout" />
|
|
|
|
<textbtn @click.native="logout()" text="logout" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<throbber-overlay v-if="loading" :text="loading" class="throbber"/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
import textbtn from '@/components/textbtn';
|
|
|
|
import textbtn from '@/components/textbtn';
|
|
|
|
import {matrix} from '@/main.js';
|
|
|
|
import {matrix} from '@/main.js';
|
|
|
|
import {cookieHandler} from "@/lib/cookieHandler";
|
|
|
|
import {cookieHandler} from "@/lib/cookieHandler";
|
|
|
|
|
|
|
|
import ThrobberOverlay from "@/components/throbberOverlay";
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
name: "login.vue",
|
|
|
|
name: "login.vue",
|
|
|
|
components: {
|
|
|
|
components: {
|
|
|
|
|
|
|
|
ThrobberOverlay,
|
|
|
|
textbtn
|
|
|
|
textbtn
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
@ -41,22 +46,38 @@ export default {
|
|
|
|
this.loginError = 'username is in wrong style';
|
|
|
|
this.loginError = 'username is in wrong style';
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.loading = 'logging in';
|
|
|
|
matrix.login(this.user, this.password, this.homeServer, (error) => {
|
|
|
|
matrix.login(this.user, this.password, this.homeServer, (error) => {
|
|
|
|
this.loginError = `login failed: ${error}`;
|
|
|
|
this.loginError = `login failed: ${error}`;
|
|
|
|
}, token => {
|
|
|
|
}, token => {
|
|
|
|
let cookie = new cookieHandler();
|
|
|
|
this.loading = 'store token';
|
|
|
|
cookie.setCookie({
|
|
|
|
this.cookie.setCookie({
|
|
|
|
baseUrl: this.homeServer,
|
|
|
|
baseUrl: this.homeServer,
|
|
|
|
userId: this.user,
|
|
|
|
userId: this.user,
|
|
|
|
accessToken: token
|
|
|
|
accessToken: token
|
|
|
|
});
|
|
|
|
});
|
|
|
|
cookie.setExpire(15);
|
|
|
|
this.cookie.setExpire(15);
|
|
|
|
cookie.store();
|
|
|
|
this.cookie.store();
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
this.$router.push('/rooms/');
|
|
|
|
this.$router.push('/rooms/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
logout(){
|
|
|
|
async logout(){
|
|
|
|
matrix.logout();
|
|
|
|
this.loading = 'logging out';
|
|
|
|
|
|
|
|
await matrix.logout();
|
|
|
|
|
|
|
|
this.loading = 'remove token';
|
|
|
|
|
|
|
|
this.cookie.setCookie({
|
|
|
|
|
|
|
|
baseUrl: undefined,
|
|
|
|
|
|
|
|
userId: undefined,
|
|
|
|
|
|
|
|
accessToken: undefined
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.cookie.setExpire(0);
|
|
|
|
|
|
|
|
this.cookie.store();
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
this.$forceUpdate();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
showLogin(){
|
|
|
|
|
|
|
|
return matrix.client === undefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data(){
|
|
|
|
data(){
|
|
|
@ -65,14 +86,19 @@ export default {
|
|
|
|
password: "",
|
|
|
|
password: "",
|
|
|
|
homeServer: "https://adb.sh",
|
|
|
|
homeServer: "https://adb.sh",
|
|
|
|
loginError: "",
|
|
|
|
loginError: "",
|
|
|
|
showLogin: (matrix.client === undefined)
|
|
|
|
cookie: new cookieHandler(),
|
|
|
|
|
|
|
|
loading: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
<style scoped>
|
|
|
|
#login{
|
|
|
|
.login{
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.loginBox{
|
|
|
|
position: absolute;
|
|
|
|
position: absolute;
|
|
|
|
top: 40%;
|
|
|
|
top: 40%;
|
|
|
|
left: 50%;
|
|
|
|
left: 50%;
|
|
|
@ -98,7 +124,12 @@ input:focus{
|
|
|
|
color: #000;
|
|
|
|
color: #000;
|
|
|
|
background-color: #fff;
|
|
|
|
background-color: #fff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.throbber{
|
|
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
|
|
top: 50%;
|
|
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (max-width: 35rem) {
|
|
|
|
@media (max-width: 35rem) {
|
|
|
|
input {
|
|
|
|
input {
|
|
|
|