This commit is contained in:
parent
7e7a6423b1
commit
b2fee65156
|
|
@ -1,34 +1,23 @@
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { createServer } from 'http';
|
import { createServer } from 'http';
|
||||||
import { createServer } from 'http';
|
|
||||||
|
|
||||||
|
|
||||||
import mongoose from "mongoose";
|
import mongoose from "mongoose";
|
||||||
import bodyParser from "body-parser";
|
import bodyParser from "body-parser";
|
||||||
import { Server } from 'socket.io';
|
import { Server } from 'socket.io';
|
||||||
|
|
||||||
import { Server } from 'socket.io';
|
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import fs from "node:fs"
|
|
||||||
|
|
||||||
import fs from "node:fs"
|
|
||||||
|
|
||||||
import apiRoutes from './routes/index.js'
|
import apiRoutes from './routes/index.js'
|
||||||
|
|
||||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
||||||
import { render_reset_form } from "./controllers/passwordReset.controllers.js";
|
import { render_reset_form } from "./controllers/passwordReset.controllers.js";
|
||||||
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const server = new createServer(app);
|
|
||||||
const io = new Server(server);
|
|
||||||
|
|
||||||
const server = new createServer(app);
|
const server = new createServer(app);
|
||||||
const io = new Server(server);
|
const io = new Server(server);
|
||||||
|
|
@ -130,7 +119,6 @@ app.get("/live/:projectId", (req, res) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handling Socket
|
// Handling Socket
|
||||||
import jwt from "jsonwebtoken";
|
|
||||||
import { VAModel, ProjectModel, ClientModel } from './models/vaModel.js';
|
import { VAModel, ProjectModel, ClientModel } from './models/vaModel.js';
|
||||||
import { ObjectId } from 'mongodb/lib/bson.js';
|
import { ObjectId } from 'mongodb/lib/bson.js';
|
||||||
|
|
||||||
|
|
@ -359,11 +347,6 @@ app.get("/live/:projectId", (req, res) => {
|
||||||
|
|
||||||
// Handling Socket
|
// Handling Socket
|
||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
import { VAModel, ProjectModel, ClientModel } from './models/vaModel.js';
|
|
||||||
import { ObjectId } from 'mongodb/lib/bson.js';
|
|
||||||
|
|
||||||
|
|
||||||
const vaSocketRespectToClient = new Map();
|
|
||||||
|
|
||||||
io.use(async (socket, next) => {
|
io.use(async (socket, next) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -211,8 +211,9 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
<h2>DocTracker Client Login</h2>
|
<img src="/public/images/logo-white-vertical.svg" alt="DocVA Logo" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="login-card">
|
<div class="login-card">
|
||||||
|
|
@ -330,301 +331,3 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html><!DOCTYPE html>
|
|
||||||
<html lang="en" data-theme="light">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>DocVA | Login</title>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
:root {
|
|
||||||
--color-bg-light: #ffffff;
|
|
||||||
--color-bg-dark: #121212;
|
|
||||||
--color-card-light: #ffffff;
|
|
||||||
--color-card-dark: #1e1e1e;
|
|
||||||
--color-text-light: #1a1a1a;
|
|
||||||
--color-text-dark: #f5f5f5;
|
|
||||||
--color-muted-light: #777;
|
|
||||||
--color-muted-dark: #aaa;
|
|
||||||
--color-primary: #0d0b57;
|
|
||||||
--color-secondary: #2b8efc;
|
|
||||||
--color-input-light: #f5f5f5;
|
|
||||||
--color-input-dark: #2a2a2a;
|
|
||||||
--radius: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme="dark"] {
|
|
||||||
--color-bg: var(--color-bg-dark);
|
|
||||||
--color-card: var(--color-card-dark);
|
|
||||||
--color-text: var(--color-text-dark);
|
|
||||||
--color-muted: var(--color-muted-dark);
|
|
||||||
--color-input: var(--color-input-dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme="light"] {
|
|
||||||
--color-bg: var(--color-bg-light);
|
|
||||||
--color-card: var(--color-card-light);
|
|
||||||
--color-text: var(--color-text-light);
|
|
||||||
--color-muted: var(--color-muted-light);
|
|
||||||
--color-input: var(--color-input-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
font-family: "Inter", sans-serif;
|
|
||||||
background-color: var(--color-bg);
|
|
||||||
color: var(--color-text);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 100vh;
|
|
||||||
transition: background-color 0.3s ease, color 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo img {
|
|
||||||
width: 170px;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo h1 {
|
|
||||||
margin: 10px 0 2px 0;
|
|
||||||
font-size: 2.3em;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--color-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo p {
|
|
||||||
color: var(--color-muted);
|
|
||||||
font-size: 0.9em;
|
|
||||||
letter-spacing: 0.05em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-card {
|
|
||||||
background-color: var(--color-card);
|
|
||||||
border-radius: var(--radius);
|
|
||||||
padding: 18px 40px 35px 40px;
|
|
||||||
/* width: 30%; */
|
|
||||||
/* max-width: 410px; */
|
|
||||||
width: 320px;
|
|
||||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
|
|
||||||
text-align: center;
|
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-card h2 {
|
|
||||||
margin-bottom: 25px;
|
|
||||||
color: var(--color-muted);
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 0.95em;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
|
||||||
width: calc(100% - 28px);
|
|
||||||
padding: 12px 14px;
|
|
||||||
margin-bottom: 18px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 10px;
|
|
||||||
background-color: var(--color-input);
|
|
||||||
color: var(--color-text);
|
|
||||||
font-size: 0.9em;
|
|
||||||
}
|
|
||||||
|
|
||||||
input:focus {
|
|
||||||
outline: 2px solid var(--color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.forgot {
|
|
||||||
display: block;
|
|
||||||
text-align: right;
|
|
||||||
font-size: 0.8em;
|
|
||||||
color: var(--color-muted);
|
|
||||||
text-decoration: none;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.forgot:hover {
|
|
||||||
color: var(--color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
width: 100%;
|
|
||||||
padding: 12px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 10px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 600;
|
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
background-color: var(--color-primary);
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover {
|
|
||||||
background-color: #0a0848;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary {
|
|
||||||
background-color: transparent;
|
|
||||||
border: 1.5px solid #ccc;
|
|
||||||
color: var(--color-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary:hover {
|
|
||||||
border-color: var(--color-secondary);
|
|
||||||
color: var(--color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
text-align: center;
|
|
||||||
color: var(--color-muted);
|
|
||||||
margin: 18px 0;
|
|
||||||
font-size: 0.85em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider::before,
|
|
||||||
.divider::after {
|
|
||||||
content: "";
|
|
||||||
flex: 1;
|
|
||||||
border-bottom: 1px solid #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider:not(:empty)::before {
|
|
||||||
margin-right: 0.75em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider:not(:empty)::after {
|
|
||||||
margin-left: 0.75em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-toggle {
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 0.9em;
|
|
||||||
color: var(--color-muted);
|
|
||||||
background: none;
|
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
transition: color 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-toggle:hover {
|
|
||||||
color: var(--color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 480px) {
|
|
||||||
.login-card {
|
|
||||||
width: 280px;
|
|
||||||
padding: 25px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo img {
|
|
||||||
width: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo h1 {
|
|
||||||
font-size: 1.8em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="logo">
|
|
||||||
<img src="/public/images/logo-white-vertical.svg" alt="DocVA Logo" />
|
|
||||||
<!-- <h1>DocVA</h1>
|
|
||||||
<p>VIRTUAL ASSISTANTS FOR DOCTORS</p> -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="login-card">
|
|
||||||
<h2>Log in to your account to continue</h2>
|
|
||||||
|
|
||||||
<form>
|
|
||||||
<input type="email" name="email" placeholder="Enter your email address *" required />
|
|
||||||
<input type="password" name="password" placeholder="Enter your password *" required />
|
|
||||||
<a href="/client/forgot-password" class="forgot">Forgot password?</a>
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary">🔒 Log in using password</button>
|
|
||||||
|
|
||||||
<div class="divider">OR</div>
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-secondary"># Log in with Email Code</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const root = document.documentElement;
|
|
||||||
|
|
||||||
function setTheme(theme) {
|
|
||||||
root.setAttribute("data-theme", theme);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSystemTheme() {
|
|
||||||
return window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
||||||
? "dark"
|
|
||||||
: "light";
|
|
||||||
}
|
|
||||||
|
|
||||||
setTheme(getSystemTheme());
|
|
||||||
|
|
||||||
document.querySelector("form").addEventListener("submit", async (e) => {
|
|
||||||
e.preventDefault(); // prevent page reload
|
|
||||||
|
|
||||||
const email = e.target.email.value.trim();
|
|
||||||
const password = e.target.password.value.trim();
|
|
||||||
|
|
||||||
if (!email || !password) {
|
|
||||||
alert("Please enter both email and password");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const userDetails = {
|
|
||||||
email,
|
|
||||||
password,
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
const res = await fetch("/api/v1/client/login", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({"userDetails": userDetails}),
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = await res.json();
|
|
||||||
|
|
||||||
if (!res.ok) {
|
|
||||||
throw new Error(data.message || "Login failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.success) {
|
|
||||||
// 🟢 Save token
|
|
||||||
localStorage.setItem("knoptpq", data.accessToken);
|
|
||||||
|
|
||||||
// 🟢 Redirect
|
|
||||||
window.location.href = "/client/dashboard";
|
|
||||||
} else {
|
|
||||||
alert("No token received. Please try again.");
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error("❌ Login error:", err);
|
|
||||||
alert(err.message || "Something went wrong while logging in");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
Loading…
Reference in New Issue