Skip to content

Commit

Permalink
chore: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
risv1 committed May 7, 2024
1 parent 6861df9 commit 768afff
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import Toaster from "@/components/ui/toast/Toaster.vue";
import { fetchUser } from "@/lib/fetchUser";
import { useAuthStore } from "@/store/auth";
import { ref, onMounted, watch } from "vue";
import { ref, onMounted } from "vue";
const { user, setUser } = useAuthStore();
Expand Down
3 changes: 0 additions & 3 deletions components/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@
<script setup>
import { useAuthStore } from "@/store/auth";
import { useToast } from "@/components/ui/toast/use-toast";
import { ToastAction } from "@/components/ui/toast";
import { ref } from "vue";
import { z, object } from "zod";
import { Input } from "@/components/ui/Input";
import { Button } from "@/components/ui/Button";
defineProps({
switchLayer: {
Expand Down
5 changes: 1 addition & 4 deletions components/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@

<script setup>
import { useToast } from "@/components/ui/toast/use-toast";
import { ToastAction } from "@/components/ui/toast";
import { h } from "vue";
import { ref } from "vue";
import { z, object } from "zod";
import { Input } from "@/components/ui/Input";
import { Button } from "@/components/ui/Button";
const { toast } = useToast();
Expand Down Expand Up @@ -103,7 +100,7 @@ const onSubmit = async (event) => {
console.log("Form submitted successfully!", res.body);
toast({
title: "Success",
description: "Registegreen successfully!",
description: "Registered successfully!",
});
} else {
throw createError({
Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export default defineNuxtConfig({
shadcn: {
prefix: '',
componentDir: './components/ui'
}
},
})
1 change: 1 addition & 0 deletions server/api/login.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default defineEventHandler(async (event) => {

setCookie(event, "token", token, { httpOnly: true });

setResponseStatus(event, 200);
return { message: "User logged in successfully.", user: user };
} catch (e: any) {
console.error("Error: ", e);
Expand Down
2 changes: 1 addition & 1 deletion server/api/logout.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import jwt from "jsonwebtoken";
export default defineEventHandler(async (event) => {
try {
const token = getCookie(event, "token") as string;
const user = jwt.verify(token, "secret");
const user = jwt.verify(token, process.env.JWT_SECRET!);
if (user) {
setCookie(event, "token", "", { expires: new Date(0) });
setResponseStatus(event, 200);
Expand Down
1 change: 1 addition & 0 deletions server/api/register.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default defineEventHandler(async (event) => {
return { message: "User not created."};
}

setResponseStatus(event, 200)
return { message: "User created successfully.", user: user };
} catch (e: any) {
console.error("Error: ", e);
Expand Down

0 comments on commit 768afff

Please sign in to comment.