2018-09-16 06:09:02 +02:00
|
|
|
<template>
|
2020-06-29 19:02:47 +02:00
|
|
|
<section class="section is-fullheight is-login">
|
|
|
|
<div class="container">
|
|
|
|
<h1 class="title">
|
|
|
|
Dashboard Access
|
|
|
|
</h1>
|
|
|
|
<h2 class="subtitle mb5">
|
|
|
|
Login to access your files and folders
|
|
|
|
</h2>
|
|
|
|
<div class="columns">
|
|
|
|
<div class="column is-4 is-offset-4">
|
|
|
|
<b-field>
|
2020-07-07 01:02:59 +02:00
|
|
|
<b-input
|
|
|
|
v-model="username"
|
2020-07-19 21:26:55 +02:00
|
|
|
class="lolisafe-input"
|
2020-06-29 19:02:47 +02:00
|
|
|
type="text"
|
|
|
|
placeholder="Username"
|
|
|
|
@keyup.enter.native="login" />
|
|
|
|
</b-field>
|
|
|
|
<b-field>
|
2020-07-07 01:02:59 +02:00
|
|
|
<b-input
|
|
|
|
v-model="password"
|
2020-07-19 21:26:55 +02:00
|
|
|
class="lolisafe-input"
|
2020-06-29 19:02:47 +02:00
|
|
|
type="password"
|
|
|
|
placeholder="Password"
|
|
|
|
password-reveal
|
|
|
|
@keyup.enter.native="login" />
|
|
|
|
</b-field>
|
2018-09-16 06:09:02 +02:00
|
|
|
|
2020-07-09 01:24:40 +02:00
|
|
|
<p class="control has-addons is-pulled-right" />
|
|
|
|
|
|
|
|
<div class="level">
|
|
|
|
<div class="level-left">
|
|
|
|
<div class="level-item">
|
|
|
|
<router-link
|
|
|
|
v-if="config.userAccounts"
|
|
|
|
to="/register"
|
|
|
|
class="is-text">
|
|
|
|
Don't have an account?
|
|
|
|
</router-link>
|
|
|
|
<span v-else>Registration is closed at the moment</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="level-right">
|
|
|
|
<p class="level-item">
|
|
|
|
<b-button
|
|
|
|
size="is-medium"
|
|
|
|
type="is-lolisafe"
|
|
|
|
@click="login">
|
|
|
|
Login
|
|
|
|
</b-button>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-09-16 06:09:02 +02:00
|
|
|
</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>
|
2020-07-02 01:50:55 +02:00
|
|
|
import { mapState } from 'vuex';
|
|
|
|
|
2018-09-16 06:09:02 +02:00
|
|
|
export default {
|
|
|
|
name: 'Login',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
username: null,
|
|
|
|
password: null,
|
|
|
|
mfaCode: null,
|
|
|
|
isMfaModalActive: false,
|
2020-12-24 09:40:50 +01:00
|
|
|
isLoading: false
|
2018-09-16 06:09:02 +02:00
|
|
|
};
|
|
|
|
},
|
2020-07-02 01:50:55 +02:00
|
|
|
computed: mapState(['config', 'auth']),
|
2018-09-16 06:09:02 +02:00
|
|
|
metaInfo() {
|
|
|
|
return { title: 'Login' };
|
|
|
|
},
|
2020-07-02 01:50:55 +02:00
|
|
|
created() {
|
|
|
|
if (this.auth.loggedIn) {
|
|
|
|
this.redirect();
|
|
|
|
}
|
|
|
|
},
|
2018-09-16 06:09:02 +02:00
|
|
|
methods: {
|
2019-03-28 16:35:58 +01:00
|
|
|
async login() {
|
2020-07-07 01:02:59 +02:00
|
|
|
if (this.isLoading) return;
|
2020-07-02 01:50:55 +02:00
|
|
|
|
|
|
|
const { username, password } = this;
|
|
|
|
if (!username || !password) {
|
2020-07-09 01:24:40 +02:00
|
|
|
this.$notifier.error('Please fill both fields before attempting to log in.');
|
2018-09-16 06:09:02 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-03-28 16:44:33 +01:00
|
|
|
|
2020-07-07 01:02:59 +02:00
|
|
|
try {
|
|
|
|
this.isLoading = true;
|
|
|
|
await this.$store.dispatch('auth/login', { username, password });
|
|
|
|
if (this.auth.loggedIn) {
|
|
|
|
this.redirect();
|
|
|
|
}
|
|
|
|
} catch (e) {
|
2020-07-09 01:24:40 +02:00
|
|
|
this.$notifier.error(e.message);
|
2020-07-07 01:02:59 +02:00
|
|
|
} finally {
|
|
|
|
this.isLoading = false;
|
2019-03-28 16:35:58 +01:00
|
|
|
}
|
2018-09-16 06:09:02 +02:00
|
|
|
},
|
|
|
|
/*
|
|
|
|
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);
|
|
|
|
});
|
2020-07-07 01:02:59 +02:00
|
|
|
}, */
|
2018-09-16 06:09:02 +02:00
|
|
|
redirect() {
|
|
|
|
if (typeof this.$route.query.redirect !== 'undefined') {
|
|
|
|
this.$router.push(this.$route.query.redirect);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.$router.push('/dashboard');
|
2020-12-24 09:40:50 +01:00
|
|
|
}
|
|
|
|
}
|
2018-09-16 06:09:02 +02:00
|
|
|
};
|
|
|
|
</script>
|