Added simple TOTP Two Factor Authentication

This commit is contained in:
Ponkhy 2021-09-09 21:10:31 +02:00
parent 2583dbe0e0
commit 403202d4d4
11 changed files with 447 additions and 15 deletions

View file

@ -4,16 +4,23 @@
<form @submit.prevent="submit">
<h1 class="h3 mb-3 fw-normal" />
<div class="form-floating">
<div v-if="!tokenRequired" class="form-floating">
<input id="floatingInput" v-model="username" type="text" class="form-control" placeholder="Username">
<label for="floatingInput">{{ $t("Username") }}</label>
</div>
<div class="form-floating mt-3">
<div v-if="!tokenRequired" class="form-floating mt-3">
<input id="floatingPassword" v-model="password" type="password" class="form-control" placeholder="Password">
<label for="floatingPassword">{{ $t("Password") }}</label>
</div>
<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>
<div class="form-check mb-3 mt-3 d-flex justify-content-center pe-4">
<div class="form-check">
<input id="remember" v-model="$root.remember" type="checkbox" value="remember-me" class="form-check-input">
@ -42,16 +49,24 @@ export default {
processing: false,
username: "",
password: "",
token: "",
res: null,
tokenRequired: false,
}
},
methods: {
submit() {
this.processing = true;
this.$root.login(this.username, this.password, (res) => {
this.$root.login(this.username, this.password, this.token, (res) => {
this.processing = false;
this.res = res;
console.log(res)
if (res.tokenRequired) {
this.tokenRequired = true;
} else {
this.res = res;
}
})
},
},