diff options
| author | Pitu <[email protected]> | 2018-09-16 01:09:02 -0300 |
|---|---|---|
| committer | Pitu <[email protected]> | 2018-09-16 01:09:02 -0300 |
| commit | fe10a00ba9a3c30d8718ca004ccd19518466f5bd (patch) | |
| tree | 369752f59a88dd03df1e9752be0ba166bf93c933 /src/site/views/Auth | |
| parent | First version of start script (diff) | |
| download | host.fuwn.me-fe10a00ba9a3c30d8718ca004ccd19518466f5bd.tar.xz host.fuwn.me-fe10a00ba9a3c30d8718ca004ccd19518466f5bd.zip | |
Site
Diffstat (limited to 'src/site/views/Auth')
| -rw-r--r-- | src/site/views/Auth/ChangePassword.vue | 178 | ||||
| -rw-r--r-- | src/site/views/Auth/ForgotPassword.vue | 152 | ||||
| -rw-r--r-- | src/site/views/Auth/Login.vue | 178 |
3 files changed, 508 insertions, 0 deletions
diff --git a/src/site/views/Auth/ChangePassword.vue b/src/site/views/Auth/ChangePassword.vue new file mode 100644 index 0000000..6854fad --- /dev/null +++ b/src/site/views/Auth/ChangePassword.vue @@ -0,0 +1,178 @@ +<style lang="scss" scoped> + @import '../../styles/colors.scss'; + + a.is-themed { + background: $basePink; + color: #fafafa; + border: none; + } + + a.is-themed:hover { + background: $basePinkHover; + border: none; + } + + body.kpop a.is-themed { background: $baseBlue; } + body.kpop a.is-themed:hover { background: $baseBlueHover; } + + a.is-text { + display: inline-flex; + padding-top: 4px; + color: #fafafa; + } + + a.is-text:hover { color: $basePink; } + body.kpop a.is-text:hover { color: $baseBlue; } + + a.text { color: white } + a.text:hover { color: #FF015B; } + + input, p.control a.button { + border-left: 0px; + border-top: 0px; + border-right: 0px; + border-radius: 0px; + box-shadow: 0 0 0; + } + + p.control a.button { margin-left: 10px; } + p.control a.button:hover { border-bottom: 1px solid #FF015B; } + p.control a#loginBtn { border-right: 0px; } + p.control a#registerBtn { border-left: 0px; } + + span.errorMessage { + display: block; + padding-top: 50px; + color: #FF015B; + } + + section.hero { + overflow: hidden; + } + + section.hero, section.hero > * { + position: relative; + } + + section.hero div.background { + content: ''; + position: fixed; + top: -50px; + left: -50px; + background: no-repeat scroll 50% 50%; + background-size: cover; + background-image: url(../../../public/images/home-background.jpg); + filter: blur(25px); + -webkit-filter: blur(25px); + z-index: 0; + height: calc(100vh + 100px); + width: calc(100% + 100px); + } + + h3 { + color: #c7c7c7; + margin-bottom: 10px; + } +</style> + +<template> + <section class="hero is-fullheight has-text-centered"> + <div class="background"/> + + <div class="hero-body"> + <div class="container"> + <router-link to="/"> + <div class="logo"> + <Logo/> + </div> + </router-link> + + <h3>Please choose a new password for your account.</h3> + <div class="columns"> + <div class="column is-4 is-offset-4"> + <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="change"/> + </b-field> + + <p class="control has-addons is-pulled-right"> + <a :class="{ 'is-loading': isLoading }" + class="button is-themed" + @click="change">Request Password Change</a> + </p> + </div> + </div> + </div> + </div> + </section> +</template> + +<script> +import Logo from '../../components/logo/Logo.vue'; + +export default { + components: { Logo }, + props: { + key: { + type: String, + default: null + }, + email: { + type: String, + default: null + } + }, + data() { + return { + password: null, + rePassword: null, + isLoading: false + }; + }, + mounted() { + this.$ga.page({ + page: '/login/change', + title: 'Change Password', + location: window.location.href + }); + + if (!this.key || !this.email) { + this.$showToast('Data is missing.', true); + this.$router.push('/'); + } + }, + methods: { + async change() { + if (this.isLoading) return; + if (this.password !== this.rePassword) { + this.$showToast('Passwords don\'t match', true); + return; + } + this.isLoading = true; + + try { + const response = await this.axios.post(`${this.$config.baseURL}/password/verify`, { + password: this.password, + verificationKey: this.key, + email: this.email + }); + this.$showToast(response.data.message); + this.isLoading = false; + this.$router.push('/login'); + } catch (error) { + this.isLoading = false; + this.$onPromiseError(error); + } + } + } +}; +</script> diff --git a/src/site/views/Auth/ForgotPassword.vue b/src/site/views/Auth/ForgotPassword.vue new file mode 100644 index 0000000..5442d16 --- /dev/null +++ b/src/site/views/Auth/ForgotPassword.vue @@ -0,0 +1,152 @@ +<style lang="scss" scoped> + @import '../../styles/colors.scss'; + + a.is-themed { + background: $basePink; + color: #fafafa; + border: none; + } + + a.is-themed:hover { + background: $basePinkHover; + border: none; + } + + body.kpop a.is-themed { background: $baseBlue; } + body.kpop a.is-themed:hover { background: $baseBlueHover; } + + a.is-text { + display: inline-flex; + padding-top: 4px; + color: #fafafa; + } + + a.is-text:hover { color: $basePink; } + body.kpop a.is-text:hover { color: $baseBlue; } + + a.text { color: white } + a.text:hover { color: #FF015B; } + + input, p.control a.button { + border-left: 0px; + border-top: 0px; + border-right: 0px; + border-radius: 0px; + box-shadow: 0 0 0; + } + + p.control a.button { margin-left: 10px; } + p.control a.button:hover { border-bottom: 1px solid #FF015B; } + p.control a#loginBtn { border-right: 0px; } + p.control a#registerBtn { border-left: 0px; } + + span.errorMessage { + display: block; + padding-top: 50px; + color: #FF015B; + } + + section.hero { + overflow: hidden; + } + + section.hero, section.hero > * { + position: relative; + } + + section.hero div.background { + content: ''; + position: fixed; + top: -50px; + left: -50px; + background: no-repeat scroll 50% 50%; + background-size: cover; + background-image: url(../../../public/images/home-background.jpg); + filter: blur(25px); + -webkit-filter: blur(25px); + z-index: 0; + height: calc(100vh + 100px); + width: calc(100% + 100px); + } + + h3 { + color: #c7c7c7; + margin-bottom: 10px; + } +</style> + +<template> + <section class="hero is-fullheight has-text-centered"> + <div class="background"/> + + <div class="hero-body"> + <div class="container"> + <router-link to="/"> + <div class="logo"> + <Logo/> + </div> + </router-link> + + <h3>To request a new password please enter your account email in the box below. <br>We will send you an email with further instructions.</h3> + <div class="columns"> + <div class="column is-4 is-offset-4"> + <b-field> + <b-input v-model="email" + type="text" + placeholder="Email"/> + </b-field> + + <p class="control has-addons is-pulled-right"> + <a :class="{ 'is-loading': isLoading }" + class="button is-themed" + @click="request">Request Password Change</a> + </p> + </div> + </div> + </div> + </div> + </section> +</template> + +<script> +import Logo from '../../components/logo/Logo.vue'; + +export default { + name: 'ForgotPassword', + components: { Logo }, + data() { + return { + email: null, + isLoading: false + }; + }, + metaInfo() { + return { title: 'Forgot password' }; + }, + mounted() { + this.$ga.page({ + page: '/login/forgot', + title: 'Forgot Password', + location: window.location.href + }); + }, + methods: { + request() { + if (this.isLoading) return; + if (!this.email || this.email === '') { + this.$showToast('Email can\'t be empty', true); + return; + } + this.isLoading = true; + this.axios.post(`${this.$config.baseURL}/password/forgot`, { email: this.email }).then(response => { + this.$showToast(response.data.message); + this.isLoading = false; + return this.$router.push('/login'); + }).catch(err => { + this.isLoading = false; + this.$onPromiseError(err); + }); + } + } +}; +</script> diff --git a/src/site/views/Auth/Login.vue b/src/site/views/Auth/Login.vue new file mode 100644 index 0000000..f5d386d --- /dev/null +++ b/src/site/views/Auth/Login.vue @@ -0,0 +1,178 @@ +<style lang="scss" scoped> + @import '../../styles/colors.scss'; +</style> +<style lang="scss"> + @import '../../styles/colors.scss'; + + section#login { background-color: $backgroundLight1 !important; } + section#login input, section#login a.button { + font-size: 14px !important; + } + section#login input, section#login p.control a.button { + border-left: 0px !important; + border-top: 0px !important; + border-right: 0px !important; + border-radius: 0px !important; + box-shadow: 0 0 0 !important; + } + + section#login p.control a.button { margin-left: 10px !important; } + section#login p.control a#loginBtn { border-right: 0px !important; } + section#login p.control a#registerBtn { border-left: 0px !important; } +</style> + +<template> + <section id="login" + class="hero is-fullheight"> + <Navbar/> + <div class="hero-body"> + <div class="container"> + <h1 class="title"> + Dashboard Access + </h1> + <h2 class="subtitle"> + Login or register + </h2> + <div class="columns"> + <div class="column"> + <b-field> + <b-input v-model="username" + type="text" + placeholder="Username / Email" + @keyup.enter.native="login"/> + </b-field> + <b-field> + <b-input v-model="password" + type="password" + placeholder="Password" + password-reveal + @keyup.enter.native="login"/> + </b-field> + + <p class="control has-addons is-pulled-right"> + <router-link id="registerBtn" + to="/register" + class="button">Register</router-link> + <a id="loginBtn" + class="button" + @click="login">Log in</a> + </p> + + </div> + <div class="column is-hidden-mobile"/> + <div class="column is-hidden-mobile"/> + </div> + </div> + </div> + + <!-- + <b-modal :active.sync="isMfaModalActive" + :canCancel="true" + has-modal-card> + <div class="card mfa"> + <div class="card-content"> + <div class="content"> + <p>Enter your Two-Factor code to proceed.</p> + <b-field> + <b-input v-model="mfaCode" + placeholder="Your MFA Code" + type="text" + @keyup.enter.native="mfa"/> + <p class="control"> + <button :class="{ 'is-loading': isLoading }" + class="button is-primary" + @click="mfa">Submit</button> + </p> + </b-field> + </div> + </div> + </div> + </b-modal> + --> + </section> +</template> + +<script> +import Navbar from '../../components/navbar/Navbar.vue'; + +export default { + name: 'Login', + components: { Navbar }, + data() { + return { + username: null, + password: null, + mfaCode: null, + isMfaModalActive: false, + isLoading: false + }; + }, + computed: { + config() { + return this.$store.state.config; + } + }, + metaInfo() { + return { title: 'Login' }; + }, + mounted() { + this.$ga.page({ + page: '/login', + title: 'Login', + location: window.location.href + }); + }, + methods: { + login() { + if (this.isLoading) return; + if (!this.username || !this.password) { + this.$showToast('Please fill both fields before attempting to log in.', true); + return; + } + this.isLoading = true; + this.axios.post(`${this.$config.baseURL}/auth/login`, { + username: this.username, + password: this.password + }).then(res => { + this.$store.commit('token', res.data.token); + this.$store.commit('user', res.data.user); + /* + if (res.data.mfa) { + this.isMfaModalActive = true; + this.isLoading = false; + } else { + this.getUserData(); + } + */ + this.redirect(); + }).catch(err => { + this.isLoading = false; + this.$onPromiseError(err); + }); + }, + /* + mfa() { + if (!this.mfaCode) return; + if (this.isLoading) return; + this.isLoading = true; + this.axios.post(`${this.$BASE_URL}/login/mfa`, { token: this.mfaCode }) + .then(res => { + this.$store.commit('token', res.data.token); + this.redirect(); + }) + .catch(err => { + this.isLoading = false; + this.$onPromiseError(err); + }); + },*/ + redirect() { + this.$store.commit('loggedIn', true); + if (typeof this.$route.query.redirect !== 'undefined') { + this.$router.push(this.$route.query.redirect); + return; + } + this.$router.push('/dashboard'); + } + } +}; +</script> |