cookies bug fix
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { inject, ref } from 'vue';
|
||||||
|
import type { VueCookies } from 'vue-cookies';
|
||||||
|
|
||||||
|
const $cookies = inject<VueCookies>("$cookies") as VueCookies;
|
||||||
|
|
||||||
const emit = defineEmits(['goBack']);
|
const emit = defineEmits(['goBack']);
|
||||||
|
|
||||||
@@ -8,8 +10,8 @@ const roomName = ref<string>();
|
|||||||
|
|
||||||
async function addRoom(e: SubmitEvent) {
|
async function addRoom(e: SubmitEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let uid = await cookieStore.get("userId");
|
let uid = await $cookies.get("userId");
|
||||||
const res = await fetch("http://localhost:3000/addRoom", {
|
const res = await fetch("/addRoom", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({ roomName: roomName.value, userid: uid?.value }),
|
body: JSON.stringify({ roomName: roomName.value, userid: uid?.value }),
|
||||||
headers: new Headers({'content-type': 'application/json'})
|
headers: new Headers({'content-type': 'application/json'})
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onBeforeMount, ref } from 'vue';
|
import { inject, onBeforeMount, ref } from 'vue';
|
||||||
|
import type { VueCookies } from 'vue-cookies';
|
||||||
|
|
||||||
|
const $cookies = inject<VueCookies>("$cookies") as VueCookies;
|
||||||
const emit = defineEmits(['goHome', 'addRoom']);
|
const emit = defineEmits(['goHome', 'addRoom']);
|
||||||
const rooms = ref();
|
const rooms = ref();
|
||||||
|
|
||||||
@@ -10,7 +12,7 @@ const day = ref<number>(1);
|
|||||||
const period = ref<number>(1);
|
const period = ref<number>(1);
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
let res = await fetch("http://localhost:3000/getRooms", {
|
let res = await fetch("/getRooms", {
|
||||||
method: "GET"
|
method: "GET"
|
||||||
});
|
});
|
||||||
rooms.value = await res.json();
|
rooms.value = await res.json();
|
||||||
@@ -18,8 +20,8 @@ onBeforeMount(async () => {
|
|||||||
|
|
||||||
async function addTimeSlot(e: SubmitEvent) {
|
async function addTimeSlot(e: SubmitEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let uid = await cookieStore.get("userId");
|
let uid = await $cookies.get("userId");
|
||||||
await fetch("http://localhost:3000/addTimeSlot", {
|
await fetch("/addTimeSlot", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({ roomid: room.value.Id, userid: uid?.value, day: (day.value * weekNumber.value), period: period.value }),
|
body: JSON.stringify({ roomid: room.value.Id, userid: uid?.value, day: (day.value * weekNumber.value), period: period.value }),
|
||||||
headers: new Headers({'content-type': 'application/json'})
|
headers: new Headers({'content-type': 'application/json'})
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ async function getData() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const day = today.getDay() * weekNumber.value;
|
const day = today.getDay() * weekNumber.value;
|
||||||
const res = await fetch("http://localhost:3000/currentRooms", {
|
const res = await fetch("/currentRooms", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({day: day}),
|
body: JSON.stringify({day: day}),
|
||||||
headers: new Headers({'content-type': 'application/json'})
|
headers: new Headers({'content-type': 'application/json'})
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { inject, ref } from 'vue';
|
||||||
|
import type { VueCookies } from 'vue-cookies';
|
||||||
|
|
||||||
|
const $cookies = inject<VueCookies>("$cookies") as VueCookies;
|
||||||
|
|
||||||
const email = ref<string>("");
|
const email = ref<string>("");
|
||||||
const pass = ref<string>("");
|
const pass = ref<string>("");
|
||||||
@@ -16,9 +19,9 @@ async function login(e: SubmitEvent) {
|
|||||||
headers: new Headers({'content-type': 'application/json'})
|
headers: new Headers({'content-type': 'application/json'})
|
||||||
});
|
});
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
cookieStore.set("loggedIn", "true");
|
$cookies.set("loggedIn", "true");
|
||||||
let uid = await res.json();
|
let uid = await res.json();
|
||||||
cookieStore.set("userId", uid.uid.Id);
|
$cookies.set("userId", uid.uid.Id);
|
||||||
emit('nextPage');
|
emit('nextPage');
|
||||||
} else {
|
} else {
|
||||||
text.value = await res.text();
|
text.value = await res.text();
|
||||||
@@ -28,7 +31,7 @@ async function login(e: SubmitEvent) {
|
|||||||
async function signup(e: Event) {
|
async function signup(e: Event) {
|
||||||
text.value = "";
|
text.value = "";
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const res = await fetch("http://localhost:3000/createUser", {
|
const res = await fetch("/createUser", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({ email: email.value, pass: pass.value, name: email.value.split("@")[0] }),
|
body: JSON.stringify({ email: email.value, pass: pass.value, name: email.value.split("@")[0] }),
|
||||||
headers: new Headers({'content-type': 'application/json'})
|
headers: new Headers({'content-type': 'application/json'})
|
||||||
|
|||||||
Reference in New Issue
Block a user