2021-07-16 22:56:41 +00:00
|
|
|
<template>
|
2021-10-28 17:55:20 +00:00
|
|
|
<div class="uk-vertical-align uk-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-07-16 22:56:41 +00:00
|
|
|
class="uk-width-1-1 uk-form-large uk-input uk-width-auto"
|
|
|
|
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-10-28 17:55:20 +00:00
|
|
|
class="uk-width-1-1 uk-form-large uk-input uk-width-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-10-31 18:36:47 +00:00
|
|
|
<a class="uk-width-1-1 uk-button uk-button-large uk-width-auto" @click="register">
|
2021-10-08 18:52:51 +00:00
|
|
|
{{ $t("titles.register") }}</a
|
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() {
|
|
|
|
document.title = "Register - Piped";
|
|
|
|
},
|
2021-07-16 22:56:41 +00:00
|
|
|
methods: {
|
|
|
|
register() {
|
|
|
|
this.fetchJson(this.apiUrl() + "/register", 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>
|