Former-commit-id: 068e447a6332149f7c621da924100bacc5a02752 [formerly 80b5e008e56b9c48ccc0450effabc7f33dfd20b4] [formerly 0f8b405cb136355711970a9d9f3f1210272101ca [formerly 85e01a67c3f9e33ad0ac7fef5eeab612f747c08b]] Former-commit-id: 03a1448741f695e2d5c681a11d9dcdca750ff61d [formerly 218dd8e95058a02cafee341dc2330c0a700972df] Former-commit-id: 0d7ebe389f3e640f6a0102e8a4b5a28e395842c0
118 lines
2.0 KiB
Vue
118 lines
2.0 KiB
Vue
<template>
|
|
<div id="login">
|
|
<form @submit="submit">
|
|
<img src="../assets/logo.svg" alt="File Manager">
|
|
<h1>File Manager</h1>
|
|
<div v-if="wrong" class="wrong">Wrong credentials</div>
|
|
<input type="text" v-model="username" placeholder="Username">
|
|
<input type="password" v-model="password" placeholder="Password">
|
|
<input type="submit" value="Login">
|
|
</form>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import auth from '@/utils/auth'
|
|
|
|
export default {
|
|
name: 'login',
|
|
data: function () {
|
|
return {
|
|
wrong: false,
|
|
username: '',
|
|
password: ''
|
|
}
|
|
},
|
|
methods: {
|
|
submit: function (event) {
|
|
event.preventDefault()
|
|
event.stopPropagation()
|
|
|
|
let redirect = this.$route.query.redirect
|
|
if (redirect === '') {
|
|
redirect = this.$store.state.baseURL + '/files/'
|
|
}
|
|
|
|
auth.login(this.username, this.password)
|
|
.then(() => {
|
|
this.$router.push({ path: redirect })
|
|
})
|
|
.catch(e => {
|
|
console.log(e)
|
|
this.wrong = true
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
#login {
|
|
background: #fff;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
#login img {
|
|
width: 4em;
|
|
height: 4em;
|
|
margin: 0 auto;
|
|
display: block;
|
|
}
|
|
|
|
#login h1 {
|
|
text-align: center;
|
|
font-size: 2.5em;
|
|
margin: .4em 0 .67em;
|
|
}
|
|
|
|
#login form {
|
|
position: fixed;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
max-width: 16em;
|
|
width: 90%;
|
|
}
|
|
|
|
#login input {
|
|
width: 100%;
|
|
width: 100%;
|
|
margin: .5em 0 0;
|
|
}
|
|
|
|
#login .wrong {
|
|
background: #F44336;
|
|
color: #fff;
|
|
padding: .5em;
|
|
text-align: center;
|
|
animation: .2s opac forwards;
|
|
}
|
|
|
|
@keyframes opac {
|
|
0% {
|
|
opacity: 0;
|
|
}
|
|
100% {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
#login input[type="text"],
|
|
#login input[type="password"] {
|
|
padding: .5em 1em;
|
|
border: 1px solid #e9e9e9;
|
|
transition: .2s ease border;
|
|
color: #333;
|
|
}
|
|
|
|
#login input[type="text"]:hover,
|
|
#login input[type="password"]:hover {
|
|
border-color: #9f9f9f;
|
|
}
|
|
</style>
|
|
|