const authSession = async (_event, payload: string | UserCreds | null): Promise<string> => {
return new Promise((resolve, reject) => {
+
console.log('authenticating...');
+
backgroundMitt.on('auth-res', (res: string) => {
+
if (res === 'locked') {
reject(res);
} else {
auth = true;
resolve(res);
}
+
});
+
if (!payload) {
socket.send('no-token');
} else if (typeof payload === 'string' || payload instanceof String) {
}
}
+// Run every time we want to connect to backend.
export const initSession = () => {
+
+ // Close existing sockets.
if (socket) {
socket.removeAllListeners();
socket.terminate();
success = false;
}
+ // Init new socket.
socket = new WebSocket(`${ip}:${port}`);
socket.binaryType = 'arraybuffer';
ipcMain.removeHandler('auth-user'); // avoid setting duplicate handlers
ipcMain.handle('auth-user', authSession);
+ // Connect to the backend.
socket.on('open', () => {
console.log('Success! Connected to Crimata Servers.');
});
+ // Handle for failed connect, try again.
socket.on('error', (_e) => {
console.log('ERROR: Failed to connect.');
socket.removeAllListeners();
+++ /dev/null
-<template>
- <div id="login">
-
- <!-- login title -->
- <div id="loginTitle">Login</div>
-
- <!-- username and password forms -->
- <div id="loginBox">
-
- <!-- username -->
- <input
- class="input"
- type="text"
- v-model="login.username"
- placeholder="username"
- />
-
- <!-- password -->
- <input
- class="input"
- type="password"
- v-model="login.password"
- placeholder="Password"
- />
-
- </div>
-
- <!-- submit button -->
- <button class="button" v-on:click="submitCreds">Submit</button>
-
- </div>
-</template>
-
-<script lang="ts">
-
-import { defineComponent } from "vue";
-
-export default defineComponent({
-
- name: "Login",
-
- data: function() {
-return {
- login: {
- username: "",
- password: ""
- }
- };
-}
-
-});
-
-</script>
-
-<style lang="scss" scoped>
-
- #login {
- width: 350px;
- height: 500px;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- background-color: #e6e6e6;
- }
-
- #loginBox {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
-
- .input {
- background-color: #B9B9B9;
- border: none;
- color: white;
- padding: 16px;
- text-decoration: none;
- margin: 4px 2px;
- cursor: pointer;
- border-radius: 10px;
- }
-
- .button {
- background-color: #58C4FD;
- border: none;
- color: white;
- padding: 10px 20px;
- text-decoration: none;
- border-radius: 20px;
- font-weight: bold;
- }
-
-</style>
\ No newline at end of file
+++ /dev/null
-<template>
- <div id="splash">
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="57.046"
- height="52.759"
- viewBox="0 0 57.046 52.759"
- >
- <g transform="translate(-4127 -507)">
- <g transform="translate(3949 332.206)">
- <g transform="translate(178 174.794)">
- <g transform="translate(0 27.405)">
- <circle
- cx="12.677"
- cy="12.677"
- r="12.677"
- transform="translate(0 0)"
- fill="#383838"
- />
- <circle
- cx="12.677"
- cy="12.677"
- r="12.677"
- transform="translate(31.692 0)"
- fill="#383838"
- />
- </g>
- <circle
- cx="12.677"
- cy="12.677"
- r="12.677"
- transform="translate(15.822 0)"
- fill="#383838"
- />
- <path
- d="M36.27,83.67"
- transform="translate(-23.569 -43.588)"
- fill="#ff0"
- />
- </g>
- </g>
- </g>
- </svg>
- </div>
-</template>
-
-<script lang="ts">
-
-import { defineComponent } from "vue";
-
-export default defineComponent({
-
- name: "Splash",
-
-});
-
-</script>
-
-<style lang="scss" scoped>
-
- #splash {
- width: 350px;
- height: 500px;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #EBEBEB;
- box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.3);
- // border-radius: 20px;
- }
-
-</style>
-
RouteRecordRaw
} from "vue-router";
import Home from "@/views/home.vue";
+import Splash from "@/views/splash.vue";
import { useAuth } from '@/modules/auth';
// Define the routes (/*) for the app here.
const routes: Array<RouteRecordRaw> = [
{
path: "/",
+ name: "splash",
+ component: Splash,
+ meta: { requiresAuth: false },
+ },
+ {
+ path: "/home",
name: "home",
component: Home,
meta: { requiresAuth: true },
<template>
- <SplashComponent />
+ <div id="splash">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="57.046"
+ height="52.759"
+ viewBox="0 0 57.046 52.759"
+ >
+ <g transform="translate(-4127 -507)">
+ <g transform="translate(3949 332.206)">
+ <g transform="translate(178 174.794)">
+ <g transform="translate(0 27.405)">
+ <circle
+ cx="12.677"
+ cy="12.677"
+ r="12.677"
+ transform="translate(0 0)"
+ fill="#383838"
+ />
+ <circle
+ cx="12.677"
+ cy="12.677"
+ r="12.677"
+ transform="translate(31.692 0)"
+ fill="#383838"
+ />
+ </g>
+ <circle
+ cx="12.677"
+ cy="12.677"
+ r="12.677"
+ transform="translate(15.822 0)"
+ fill="#383838"
+ />
+ <path
+ d="M36.27,83.67"
+ transform="translate(-23.569 -43.588)"
+ fill="#ff0"
+ />
+ </g>
+ </g>
+ </g>
+ </svg>
+ </div>
</template>
<script lang="ts">
});
-</script>
\ No newline at end of file
+</script>
+
+<style lang="scss" scoped>
+
+ #splash {
+ width: 350px;
+ height: 500px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background-color: #EBEBEB;
+ box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.3);
+ // border-radius: 20px;
+ }
+
+</style>
\ No newline at end of file