2021-06-25 09:55:49 -04:00
|
|
|
<template>
|
|
|
|
<div class="form-container">
|
|
|
|
<div class="form">
|
|
|
|
<form @submit.prevent="submit">
|
2021-07-27 13:47:13 -04:00
|
|
|
<h1 class="h3 mb-3 fw-normal" />
|
2021-06-25 09:55:49 -04:00
|
|
|
|
2021-09-09 15:10:31 -04:00
|
|
|
<div v-if="!tokenRequired" class="form-floating">
|
2021-07-27 13:47:13 -04:00
|
|
|
<input id="floatingInput" v-model="username" type="text" class="form-control" placeholder="Username">
|
2021-08-24 06:26:44 -04:00
|
|
|
<label for="floatingInput">{{ $t("Username") }}</label>
|
2021-06-25 09:55:49 -04:00
|
|
|
</div>
|
|
|
|
|
2021-09-09 15:10:31 -04:00
|
|
|
<div v-if="!tokenRequired" class="form-floating mt-3">
|
2021-07-27 13:47:13 -04:00
|
|
|
<input id="floatingPassword" v-model="password" type="password" class="form-control" placeholder="Password">
|
2021-08-24 06:26:44 -04:00
|
|
|
<label for="floatingPassword">{{ $t("Password") }}</label>
|
2021-06-25 09:55:49 -04:00
|
|
|
</div>
|
|
|
|
|
2021-09-09 15:10:31 -04:00
|
|
|
<div v-if="tokenRequired">
|
|
|
|
<div class="form-floating mt-3">
|
|
|
|
<input id="floatingToken" v-model="token" type="text" maxlength="6" class="form-control" placeholder="123456">
|
|
|
|
<label for="floatingToken">{{ $t("Token") }}</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-07-18 07:22:39 -04:00
|
|
|
<div class="form-check mb-3 mt-3 d-flex justify-content-center pe-4">
|
2021-07-18 07:00:59 -04:00
|
|
|
<div class="form-check">
|
2021-07-27 13:47:13 -04:00
|
|
|
<input id="remember" v-model="$root.remember" type="checkbox" value="remember-me" class="form-check-input">
|
2021-06-25 09:55:49 -04:00
|
|
|
|
|
|
|
<label class="form-check-label" for="remember">
|
2021-08-24 06:26:44 -04:00
|
|
|
{{ $t("Remember me") }}
|
2021-06-25 09:55:49 -04:00
|
|
|
</label>
|
2021-07-18 07:00:59 -04:00
|
|
|
</div>
|
2021-06-25 09:55:49 -04:00
|
|
|
</div>
|
2021-07-27 13:47:13 -04:00
|
|
|
<button class="w-100 btn btn-primary" type="submit" :disabled="processing">
|
2021-08-24 06:26:44 -04:00
|
|
|
{{ $t("Login") }}
|
2021-07-27 13:47:13 -04:00
|
|
|
</button>
|
2021-06-25 09:55:49 -04:00
|
|
|
|
2021-07-27 13:47:13 -04:00
|
|
|
<div v-if="res && !res.ok" class="alert alert-danger mt-3" role="alert">
|
2021-06-25 09:55:49 -04:00
|
|
|
{{ res.msg }}
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
processing: false,
|
|
|
|
username: "",
|
|
|
|
password: "",
|
2021-09-09 15:10:31 -04:00
|
|
|
token: "",
|
2021-06-25 09:55:49 -04:00
|
|
|
res: null,
|
2021-09-09 15:10:31 -04:00
|
|
|
tokenRequired: false,
|
2021-10-01 09:07:05 -04:00
|
|
|
};
|
2021-06-25 09:55:49 -04:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
submit() {
|
|
|
|
this.processing = true;
|
2021-09-09 15:10:31 -04:00
|
|
|
|
|
|
|
this.$root.login(this.username, this.password, this.token, (res) => {
|
2021-06-25 09:55:49 -04:00
|
|
|
this.processing = false;
|
2021-09-09 15:10:31 -04:00
|
|
|
|
|
|
|
if (res.tokenRequired) {
|
|
|
|
this.tokenRequired = true;
|
|
|
|
} else {
|
|
|
|
this.res = res;
|
|
|
|
}
|
2021-10-01 09:07:05 -04:00
|
|
|
});
|
2021-07-27 13:47:13 -04:00
|
|
|
},
|
|
|
|
},
|
2021-10-01 09:07:05 -04:00
|
|
|
};
|
2021-06-25 09:55:49 -04:00
|
|
|
</script>
|
|
|
|
|
2021-10-01 09:07:05 -04:00
|
|
|
<style lang="scss" scoped>
|
2021-06-25 09:55:49 -04:00
|
|
|
.form-container {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding-top: 40px;
|
|
|
|
padding-bottom: 40px;
|
|
|
|
}
|
|
|
|
|
2021-10-01 09:07:05 -04:00
|
|
|
.form-floating {
|
|
|
|
> label {
|
|
|
|
padding-left: 1.3rem;
|
|
|
|
}
|
2021-06-25 09:55:49 -04:00
|
|
|
|
2021-10-01 09:07:05 -04:00
|
|
|
> .form-control {
|
|
|
|
padding-left: 1.3rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.form {
|
2021-06-25 09:55:49 -04:00
|
|
|
width: 100%;
|
|
|
|
max-width: 330px;
|
|
|
|
padding: 15px;
|
|
|
|
margin: auto;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
</style>
|