diff --git a/backend/index.js b/backend/index.js
index e3161bd..106a9a1 100644
--- a/backend/index.js
+++ b/backend/index.js
@@ -13,12 +13,16 @@ app.use(e.json());
app.use(bodyParser.json());
app.get('/', (req, res) => {
- res.send("Hello World");
+ res.send("Nothing Here");
});
app.get('/currentRooms', (req, res) => {
// req has no data
// res has all room at current time
+ let stmt = db.prepare(`SELECT * FROM TimeSlots`);
+ let records = stmt.all();
+ res.status(200).json({records: records});
+ console.log("currentRooms");
});
app.get('/addTimeslot', (req, res) => {
@@ -50,6 +54,7 @@ app.post('/createUser', async (req, res) => {
stmt = db.prepare(`INSERT INTO Users (Email, Pass, Username, Submissions) VALUES ('${body.email}', '${generatedHash}', '${body.name}', 0)`);
stmt.run();
res.status(200).send("account created");
+ console.log("sign up");
});
app.post('/login', async (req, res) => {
@@ -64,6 +69,7 @@ app.post('/login', async (req, res) => {
}
if (await bcrypt.compare(body.pass, storedHash.Pass)){
res.send(200);
+ console.log("login");
} else {
res.status(400).send("incorrect password");
}
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index ee93182..dbbdb66 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -8,7 +8,8 @@
"name": "frontend",
"version": "0.0.0",
"dependencies": {
- "vue": "^3.5.30"
+ "vue": "^3.5.30",
+ "vue-cookies": "^1.8.6"
},
"devDependencies": {
"@types/bcrypt": "^6.0.0",
@@ -1243,6 +1244,12 @@
}
}
},
+ "node_modules/vue-cookies": {
+ "version": "1.8.6",
+ "resolved": "https://registry.npmjs.org/vue-cookies/-/vue-cookies-1.8.6.tgz",
+ "integrity": "sha512-e2kYaHj1Y/zVsBSM3KWlOoVJ5o3l4QZjytNU7xdCgmkw3521CMUerqHekBGZKXXC1oRxYljBeeOK2SCel6cKuw==",
+ "license": "MIT"
+ },
"node_modules/vue-tsc": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-3.2.6.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 4113828..8511a53 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -9,7 +9,8 @@
"preview": "vite preview"
},
"dependencies": {
- "vue": "^3.5.30"
+ "vue": "^3.5.30",
+ "vue-cookies": "^1.8.6"
},
"devDependencies": {
"@types/bcrypt": "^6.0.0",
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index f4643db..5128b3a 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -1,7 +1,19 @@
-
+
+
diff --git a/frontend/src/components/HomePage.vue b/frontend/src/components/HomePage.vue
new file mode 100644
index 0000000..04e41ed
--- /dev/null
+++ b/frontend/src/components/HomePage.vue
@@ -0,0 +1,27 @@
+
+
+
+ What's free in my free?
+
+
+
+ Free Rooms:
+ No free rooms right now
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/Login.vue b/frontend/src/components/Login.vue
index 8ce391f..95c5f17 100644
--- a/frontend/src/components/Login.vue
+++ b/frontend/src/components/Login.vue
@@ -3,23 +3,40 @@ import { ref } from 'vue';
const email = ref("");
const pass = ref("");
+const text = ref("");
-function login(e: SubmitEvent) {
+const emit = defineEmits(['nextPage']);
+
+async function login(e: SubmitEvent) {
+ text.value = "";
e.preventDefault();
- fetch("http://localhost:3000/login", {
+ const res = await fetch("http://localhost:3000/login", {
method: "POST",
body: JSON.stringify({ email: email.value, pass: pass.value }),
headers: new Headers({'content-type': 'application/json'})
});
+ if (res.ok) {
+ cookieStore.set("loggedIn", "true");
+ emit('nextPage');
+ } else {
+ text.value = await res.text();
+ }
}
-function signup(e: Event) {
+async function signup(e: Event) {
+ text.value = "";
e.preventDefault();
- fetch("http://localhost:3000/createUser", {
+ const res = await fetch("http://localhost:3000/createUser", {
method: "POST",
body: JSON.stringify({ email: email.value, pass: pass.value, name: email.value.split("@")[0] }),
headers: new Headers({'content-type': 'application/json'})
});
+ if (res.ok) {
+ cookieStore.set("loggedIn", "true");
+ emit('nextPage');
+ } else {
+ text.value = await res.text();
+ }
}
@@ -32,5 +49,6 @@ function signup(e: Event) {
+ {{ text }}
\ No newline at end of file
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index e15756a..3a45fdf 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -1,5 +1,6 @@
-import { createApp } from 'vue'
+import { createApp } from 'vue';
// import './style.css'
-import App from './App.vue'
+import App from './App.vue';
+import VueCookies from 'vue-cookies';
-createApp(App).mount('#app')
+createApp(App).use(VueCookies).mount('#app');