uptime-kuma/src/components/Login.vue

101 lines
2.9 KiB
Vue
Raw Normal View History

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
<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">
<label for="floatingInput">{{ $t("Username") }}</label>
2021-06-25 09:55:49 -04:00
</div>
<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">
<label for="floatingPassword">{{ $t("Password") }}</label>
2021-06-25 09:55:49 -04:00
</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>
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">
{{ $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">
{{ $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: "",
token: "",
2021-06-25 09:55:49 -04:00
res: null,
tokenRequired: false,
};
2021-06-25 09:55:49 -04:00
},
methods: {
submit() {
this.processing = true;
this.$root.login(this.username, this.password, this.token, (res) => {
2021-06-25 09:55:49 -04:00
this.processing = false;
if (res.tokenRequired) {
this.tokenRequired = true;
} else {
this.res = res;
}
});
2021-07-27 13:47:13 -04:00
},
},
};
2021-06-25 09:55:49 -04:00
</script>
<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;
}
.form-floating {
> label {
padding-left: 1.3rem;
}
2021-06-25 09:55:49 -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>