2021-07-16 22:56:41 +00:00
|
|
|
<template>
|
2021-12-27 14:46:26 +00:00
|
|
|
<div class="uk-vertical-align text-center uk-height-1-1">
|
2021-07-16 22:56:41 +00:00
|
|
|
<form class="uk-panel uk-panel-box">
|
|
|
|
<div class="uk-form-row">
|
|
|
|
<input
|
2021-10-08 18:52:51 +00:00
|
|
|
v-model="username"
|
2021-12-27 14:46:29 +00:00
|
|
|
class="uk-width-1-1 uk-form-large input w-auto"
|
2021-07-16 22:56:41 +00:00
|
|
|
type="text"
|
|
|
|
autocomplete="username"
|
2021-09-21 21:58:25 +00:00
|
|
|
:placeholder="$t('login.username')"
|
|
|
|
:aria-label="$t('login.username')"
|
2021-07-16 22:56:41 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="uk-form-row">
|
|
|
|
<input
|
2021-10-08 18:52:51 +00:00
|
|
|
v-model="password"
|
2021-12-27 14:46:29 +00:00
|
|
|
class="uk-width-1-1 uk-form-large input w-auto"
|
2021-07-16 22:56:41 +00:00
|
|
|
type="password"
|
|
|
|
autocomplete="password"
|
2021-09-21 21:58:25 +00:00
|
|
|
:placeholder="$t('login.password')"
|
|
|
|
:aria-label="$t('login.password')"
|
2021-07-16 22:56:41 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="uk-form-row">
|
2021-12-27 16:29:25 +00:00
|
|
|
<a class="uk-width-1-1 uk-button uk-button-large w-auto" @click="login" v-text="$t('titles.login')" />
|
2021-07-16 22:56:41 +00:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
username: null,
|
|
|
|
password: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
//TODO: Add Server Side check
|
|
|
|
if (this.getAuthToken()) {
|
|
|
|
this.$router.push("/");
|
|
|
|
}
|
|
|
|
},
|
2021-07-21 10:59:53 +00:00
|
|
|
activated() {
|
2021-08-25 16:30:21 +00:00
|
|
|
document.title = this.$t("titles.login") + " - Piped";
|
2021-07-21 10:59:53 +00:00
|
|
|
},
|
2021-07-16 22:56:41 +00:00
|
|
|
methods: {
|
|
|
|
login() {
|
|
|
|
this.fetchJson(this.apiUrl() + "/login", null, {
|
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify({
|
|
|
|
username: this.username,
|
|
|
|
password: this.password,
|
|
|
|
}),
|
|
|
|
}).then(resp => {
|
|
|
|
if (resp.token) {
|
|
|
|
this.setPreference("authToken" + this.hashCode(this.apiUrl()), resp.token);
|
|
|
|
window.location = "/"; // done to bypass cache
|
|
|
|
} else alert(resp.error);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|