diff options
| author | Pitu <[email protected]> | 2018-09-19 04:45:50 -0300 |
|---|---|---|
| committer | Pitu <[email protected]> | 2018-09-19 04:45:50 -0300 |
| commit | 430af8306b1ab17e59a6dabf8f65ab816d28695d (patch) | |
| tree | 975814e80919cc7b8c5d820080a30def32a371ea /src/site/pages/register.vue | |
| parent | Some adjustements to public album view (diff) | |
| download | host.fuwn.me-430af8306b1ab17e59a6dabf8f65ab816d28695d.tar.xz host.fuwn.me-430af8306b1ab17e59a6dabf8f65ab816d28695d.zip | |
Switch to Nuxt.js
Diffstat (limited to 'src/site/pages/register.vue')
| -rw-r--r-- | src/site/pages/register.vue | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/site/pages/register.vue b/src/site/pages/register.vue new file mode 100644 index 0000000..c331f36 --- /dev/null +++ b/src/site/pages/register.vue @@ -0,0 +1,103 @@ +<style lang="scss" scoped> + @import '~/assets/styles/_colors.scss'; +</style> + +<template> + <section id="register" + class="hero is-fullheight"> + <Navbar/> + <div class="hero-body"> + <div class="container"> + <h1 class="title"> + Dashboard Access + </h1> + <h2 class="subtitle"> + Register for a new account + </h2> + <div class="columns"> + <div class="column is-4"> + <b-field> + <b-input v-model="username" + type="text" + placeholder="Username" /> + </b-field> + <b-field> + <b-input v-model="password" + type="password" + placeholder="Password" + password-reveal /> + </b-field> + <b-field> + <b-input v-model="rePassword" + type="password" + placeholder="Re-type Password" + password-reveal + @keyup.enter.native="register" /> + </b-field> + + <p class="control has-addons is-pulled-right"> + <router-link to="/login" + class="is-text">Already have an account?</router-link> + <a :class="{ 'is-loading': isLoading }" + class="button is-themed" + @click="register">Register</a> + </p> + </div> + </div> + </div> + </div> + </section> +</template> + +<script> +import Navbar from '~/components/navbar/Navbar.vue'; + +export default { + name: 'Register', + components: { Navbar }, + data() { + return { + username: null, + password: null, + rePassword: null, + isLoading: false + }; + }, + computed: { + config() { + return this.$store.state.config; + } + }, + metaInfo() { + return { title: 'Register' }; + }, + mounted() { + this.$ga.page({ + page: '/register', + title: 'Register', + location: window.location.href + }); + }, + methods: { + register() { + if (this.isLoading) return; + if (this.password !== this.rePassword) { + this.$showToast('Passwords don\'t match', true); + return; + } + this.isLoading = true; + this.axios.post(`${this.config.baseURL}/auth/register`, { + username: this.username, + password: this.password + }).then(response => { + this.$showToast(response.data.message); + this.isLoading = false; + return this.$router.push('/login'); + }).catch(err => { + this.isLoading = false; + this.$onPromiseError(err); + }); + } + } +}; +</script> |