93 lines
1.8 KiB
Vue
93 lines
1.8 KiB
Vue
<template>
|
|
<div class="login-wrapper">
|
|
<form @submit.prevent="goLogin">
|
|
<panel>
|
|
<div class="error" v-if="error">{{error}}</div>
|
|
<input v-model="password" type="password" autofocus @input="resetError"/>
|
|
<button @clicked="goLogin" type="submit">Authenticate</button>
|
|
</panel>
|
|
</form>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from "axios";
|
|
import Panel from "../components/Panel.vue";
|
|
|
|
export default {
|
|
name: "Login",
|
|
components: {
|
|
Panel
|
|
},
|
|
data() {
|
|
return {
|
|
password: "",
|
|
error: ""
|
|
};
|
|
},
|
|
methods: {
|
|
resetError() {
|
|
this.error = "";
|
|
},
|
|
async goLogin() {
|
|
const response = await axios.post("/api/authorize", {
|
|
password: this.password,
|
|
});
|
|
if (response.status == 200) {
|
|
localStorage.setItem("token", response.data.token);
|
|
this.$router.push("/");
|
|
} else {
|
|
this.error = "Could not authenticate";
|
|
}
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
.login-wrapper {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: grid;
|
|
grid-template-columns: 1fr;
|
|
grid-template-rows: 100vh;
|
|
align-items: center;
|
|
justify-items: center; /* adjusted */
|
|
}
|
|
input {
|
|
background: #333;
|
|
font-size: 20px;
|
|
color: #fff;
|
|
background: #121212;
|
|
font-weight: bold;
|
|
padding: 12px 22px;
|
|
border-radius: 4px;
|
|
border: 1px solid #777;
|
|
margin-bottom: 15px;
|
|
}
|
|
button {
|
|
transition: all 0.2s;
|
|
padding: 10px 18px;
|
|
background: #333;
|
|
color: #fff;
|
|
font-weight: bold;
|
|
border: 1px solid #000;
|
|
background: #121212;
|
|
box-shadow: none;
|
|
}
|
|
button:hover {
|
|
transition: all 0.2s;
|
|
box-shadow: rgba(0, 0, 0, 0.25) 0px 14px 28px,
|
|
rgba(0, 0, 0, 0.22) 0px 10px 10px;
|
|
}
|
|
.error {
|
|
color: #f33;
|
|
background: #311;
|
|
border-radius: 5px;
|
|
margin-bottom: 10px;
|
|
font-size: 16px;
|
|
font-weight: bold;
|
|
padding: 8px 12px;
|
|
}
|
|
</style>>
|