2019-02-18 09:18:32 +00:00
|
|
|
<template>
|
2019-08-03 19:03:45 +00:00
|
|
|
<div id="sign-in" class="window" role="tabpanel" aria-label="Sign-in">
|
|
|
|
<form class="container" method="post" action="" @submit="onSubmit">
|
2019-02-18 09:18:32 +00:00
|
|
|
<img
|
|
|
|
src="img/logo-vertical-transparent-bg.svg"
|
|
|
|
class="logo"
|
|
|
|
alt="The Lounge"
|
|
|
|
width="256"
|
2019-03-01 14:18:16 +00:00
|
|
|
height="170"
|
2019-08-03 19:03:45 +00:00
|
|
|
/>
|
2019-02-18 09:18:32 +00:00
|
|
|
<img
|
|
|
|
src="img/logo-vertical-transparent-bg-inverted.svg"
|
|
|
|
class="logo-inverted"
|
|
|
|
alt="The Lounge"
|
|
|
|
width="256"
|
2019-03-01 14:18:16 +00:00
|
|
|
height="170"
|
2019-08-03 19:03:45 +00:00
|
|
|
/>
|
2019-02-18 09:18:32 +00:00
|
|
|
|
|
|
|
<label for="signin-username">Username</label>
|
|
|
|
<input
|
|
|
|
id="signin-username"
|
2023-06-18 13:12:41 +00:00
|
|
|
v-model="username"
|
2019-02-18 09:18:32 +00:00
|
|
|
class="input"
|
|
|
|
type="text"
|
|
|
|
name="username"
|
|
|
|
autocapitalize="none"
|
|
|
|
autocorrect="off"
|
|
|
|
autocomplete="username"
|
|
|
|
required
|
2019-03-01 14:18:16 +00:00
|
|
|
autofocus
|
2019-08-03 19:03:45 +00:00
|
|
|
/>
|
2019-02-18 09:18:32 +00:00
|
|
|
|
|
|
|
<div class="password-container">
|
|
|
|
<label for="signin-password">Password</label>
|
|
|
|
<RevealPassword v-slot:default="slotProps">
|
|
|
|
<input
|
|
|
|
id="signin-password"
|
2023-06-18 13:12:41 +00:00
|
|
|
v-model="password"
|
2019-02-18 09:18:32 +00:00
|
|
|
:type="slotProps.isVisible ? 'text' : 'password'"
|
|
|
|
class="input"
|
|
|
|
autocapitalize="none"
|
|
|
|
autocorrect="off"
|
|
|
|
autocomplete="current-password"
|
2019-03-01 14:18:16 +00:00
|
|
|
required
|
2019-08-03 19:03:45 +00:00
|
|
|
/>
|
2019-02-18 09:18:32 +00:00
|
|
|
</RevealPassword>
|
|
|
|
</div>
|
|
|
|
|
2019-08-03 19:03:45 +00:00
|
|
|
<div v-if="errorShown" class="error">Authentication failed.</div>
|
2019-02-18 09:18:32 +00:00
|
|
|
|
2019-08-03 19:03:45 +00:00
|
|
|
<button :disabled="inFlight" type="submit" class="btn">Sign in</button>
|
2019-02-18 09:18:32 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
<script lang="ts">
|
2019-11-16 17:24:03 +00:00
|
|
|
import storage from "../../js/localStorage";
|
2019-02-18 09:18:32 +00:00
|
|
|
import socket from "../../js/socket";
|
|
|
|
import RevealPassword from "../RevealPassword.vue";
|
2022-06-19 00:25:21 +00:00
|
|
|
import {defineComponent, onBeforeUnmount, onMounted, ref} from "vue";
|
2019-02-18 09:18:32 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
export default defineComponent({
|
2019-02-18 09:18:32 +00:00
|
|
|
name: "SignIn",
|
|
|
|
components: {
|
|
|
|
RevealPassword,
|
|
|
|
},
|
2022-06-19 00:25:21 +00:00
|
|
|
setup() {
|
|
|
|
const inFlight = ref(false);
|
|
|
|
const errorShown = ref(false);
|
|
|
|
|
2023-06-18 13:12:41 +00:00
|
|
|
const username = ref(storage.get("user") || "");
|
|
|
|
const password = ref("");
|
2022-06-19 00:25:21 +00:00
|
|
|
|
|
|
|
const onAuthFailed = () => {
|
|
|
|
inFlight.value = false;
|
|
|
|
errorShown.value = true;
|
2019-02-18 09:18:32 +00:00
|
|
|
};
|
2022-06-19 00:25:21 +00:00
|
|
|
|
|
|
|
const onSubmit = (event: Event) => {
|
2019-02-18 09:18:32 +00:00
|
|
|
event.preventDefault();
|
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
if (!username.value || !password.value) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
inFlight.value = true;
|
|
|
|
errorShown.value = false;
|
2019-02-18 09:18:32 +00:00
|
|
|
|
|
|
|
const values = {
|
2023-06-18 13:12:41 +00:00
|
|
|
user: username.value,
|
|
|
|
password: password.value,
|
2019-02-18 09:18:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
storage.set("user", values.user);
|
|
|
|
|
2019-11-05 19:29:51 +00:00
|
|
|
socket.emit("auth:perform", values);
|
2022-06-19 00:25:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
socket.on("auth:failed", onAuthFailed);
|
|
|
|
});
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
socket.off("auth:failed", onAuthFailed);
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
inFlight,
|
|
|
|
errorShown,
|
|
|
|
username,
|
|
|
|
password,
|
|
|
|
onSubmit,
|
|
|
|
};
|
2019-02-18 09:18:32 +00:00
|
|
|
},
|
2022-06-19 00:25:21 +00:00
|
|
|
});
|
2019-02-18 09:18:32 +00:00
|
|
|
</script>
|