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