2021-07-16 22:56:41 +00:00
|
|
|
<template>
|
2022-07-20 20:20:10 +00:00
|
|
|
<h1 v-t="'titles.register'" class="font-bold text-center my-4" />
|
|
|
|
<hr />
|
2022-01-12 12:13:04 +00:00
|
|
|
<div class="text-center">
|
|
|
|
<form class="children:pb-3">
|
|
|
|
<div>
|
2021-07-16 22:56:41 +00:00
|
|
|
<input
|
2021-10-08 18:52:51 +00:00
|
|
|
v-model="username"
|
2022-01-12 12:13:04 +00:00
|
|
|
class="input"
|
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>
|
2022-01-12 12:13:04 +00:00
|
|
|
<div>
|
2021-07-16 22:56:41 +00:00
|
|
|
<input
|
2021-10-08 18:52:51 +00:00
|
|
|
v-model="password"
|
2022-01-12 12:13:04 +00:00
|
|
|
class="input"
|
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>
|
2022-01-12 12:13:04 +00:00
|
|
|
<div>
|
2022-01-30 23:48:27 +00:00
|
|
|
<a class="btn w-auto" @click="register" v-t="'titles.register'" />
|
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>
|