]> Repos - mime-chat/commitdiff
remove .env file(electron not picking it up)
authorEnrique Hernandez <hernandeze2@xavier.edu>
Thu, 3 Jun 2021 01:11:53 +0000 (21:11 -0400)
committerEnrique Hernandez <hernandeze2@xavier.edu>
Thu, 3 Jun 2021 01:11:53 +0000 (21:11 -0400)
.env [deleted file]
src/App.vue
src/background.ts
src/background/ipc/account.ts
src/background/session.ts
src/background/websockets.ts
src/components/login.vue
src/ipcRend/session.ts
src/main.ts
src/modules/http.ts

diff --git a/.env b/.env
deleted file mode 100644 (file)
index 6aa5026..0000000
--- a/.env
+++ /dev/null
@@ -1,4 +0,0 @@
-
-BUSINESS_URL="http://localhost:3000"
-
-PLATFORM_URL="ws://127.0.0.1:8760"
index 5a29c17fef61b23420ee734e8b66130bc86e00a6..52e44e673af778031624ff6da6870d6514d4bd4a 100644 (file)
@@ -85,8 +85,14 @@ export default defineComponent({
 
     }
 
+    const onSessionAuthFail = (_event: IpcRendererEvent, _payload: null) => {
+        clearProfile();
+    }
+
     onMounted(async () => {
       console.log("APP:mounted.");
+
+      window.ipcRenderer.on("session-auth-fail", onSessionAuthFail)
       window.ipcRenderer.on("update-state", updateState)
       window.ipcRenderer.on("update_available", () => {
           console.log('testing auto update');
@@ -117,6 +123,7 @@ export default defineComponent({
 
     onUnmounted(() => {
       window.ipcRenderer.removeAllListeners("update-state");
+      window.ipcRenderer.removeAllListeners("session-auth-fail");
     })
 
     return {
index 1ecee8380e50ba418692a8fbfa1d5e0b4927dc74..b67e8296dbb0aedb489a3ea134e1a67cb96df3e8 100644 (file)
@@ -18,9 +18,9 @@ protocol.registerSchemesAsPrivileged([
 const isDev = require('electron-is-dev');
 
 // NOTE Program Begins Here
-(async () => {
+(() => {
 
     console.log('Starting Crimata electron app.');
-    await initApp(isDev);
+    initApp(isDev);
 
 })();
index c336ac35a7bd3c54e2c19c0ab01dad09a6a4197e..c9594be1647b432d5548da92963387b7987881f6 100644 (file)
@@ -70,7 +70,7 @@ const onLogin = async (
                 resolve(parsed.profile);
 
             } catch(e) {
-                console.log('[API]', e.response);
+                console.log('[API]', e);
                 reject(new Error('Failed to authenticate'));
             }
         }
index 0fed780fbc94a0e45d49d605c50cd922798af963..fac657219a3614c43ca8e3a0bf85016e3cb5f785 100644 (file)
@@ -26,7 +26,10 @@ let state: SessionState;
 // Calls appropriate endpoint for a server message.
 const onMessage = (data: string): void => {
     let message = JSON.parse(data);
-    console.log('received new message', message);
+    if (message === "CLOSE_AUTH_FAIL") {
+        ipcEmit("session-auth-fail", null)
+        return;
+    }
 
     // Standard message.
     if (message.content) {
index 6f1abc284b12a84ee098b51db6e5542c7e3700da..5556ece17d46eb711f5562624c8f568a7932a1bd 100644 (file)
@@ -4,7 +4,7 @@ import WebSocket from 'ws';
 
 let socket: WebSocket;
 
-const socketUrl = process.env.PLATFORM_URL;
+const socketUrl = "ws://127.0.0.1:8760"
 
 // Run every time we want to connect to backend.
 export default function useWebSockets(
@@ -53,7 +53,7 @@ export default function useWebSockets(
 
     }
 
-    const onClose = (_event: WebSocket.CloseEvent) => {
+    const onClose = (event: WebSocket.CloseEvent) => {
         console.log("WS:Socket closed normally.")
     }
 
@@ -69,7 +69,6 @@ export default function useWebSockets(
         token: string;
         crimataId: string;
     }) => {
-        if (socketUrl)
         socket = new WebSocket(socketUrl)
 
         // Add listeners.
index 8232a671bf05ecde82d9a812a0a6505d0027afc6..2cb82f85090702bc9ec794672a88e842e40cd897 100644 (file)
@@ -40,13 +40,14 @@ import { authRequest } from '@/modules/message';
 import { useProfile } from '@/modules/auth';
 import { invokeLogin } from "@/ipcRend/account";
 import { Profile } from "@/types";
+import { postInitSession } from "@/ipcRend/session";
 
 export default defineComponent({
   name: "Login",
 
   setup() {
 
-    const { setProfile } = useProfile();
+    const { profile, setProfile } = useProfile();
 
     const usr = ref("");
     const pwd = ref("");
@@ -63,6 +64,13 @@ export default defineComponent({
           setProfile(profile);
 
       } catch(e) {
+        console.log('Error login in.')
+      } finally{
+
+          if (profile.value.crimataId) {
+              // start session
+              postInitSession(profile.value.crimataId);
+          }
 
       }
     }
index 966b12118a9692e7ee124395e235929987b97e7b..2eb4405d9a7ad61589b247137a76b699855a602f 100644 (file)
@@ -19,3 +19,5 @@ export const postInitSession = (cid: string): void => (
 export const postMessage = (payload: ClientMessage): void => (
     post('client-message', payload)
 );
+
+
index 35774f707853e425c089339c4d0fa8b35bd8a65e..68cc98ee62814c73d39583b35c200f527e0f98dc 100644 (file)
@@ -4,6 +4,7 @@ import App from "./App.vue";
 
 import mitt from "mitt";
 import { createApp } from "vue";
+require('dotenv').config()
 
 
 // Handle events.
index de241e0938ff2007ca377d80c411ed2921444693..a9519a81bfd8fd3270ea24934c9959b4f222dbeb 100644 (file)
@@ -3,7 +3,7 @@ import axios, { AxiosRequestConfig } from 'axios';
 
 const preFix = '/api';
 
-const baseURL = process.env.BUSSINESS_URL + preFix;
+const baseURL = "http://127.0.0.1:3000" + preFix;
 
 
 interface Request {