Compare commits

..

No commits in common. "4fe1e34a3e509afd5d7b7cac5fe98b6793d006ae" and "f0b107c2fd4537c3553ea462fb3daf891a51471f" have entirely different histories.

13 changed files with 75 additions and 116 deletions

View File

@ -46,8 +46,4 @@
body {
margin: 0 !important;
}
body[data-theme="dark"] {
color: #fff;
}
</style>

View File

@ -18,28 +18,26 @@ ${p.error.stack}
`;
</script>
<template>
<a-extract-style>
<a-typography-title> We ran into an issue.... :( <br /></a-typography-title>
<a-typography-paragraph
style="font-size: 125%"
:copyable="{
text: copied,
tooltip: true,
onCopy: () => {
setTimeout(() => {
clearError({ redirect: '/' });
navigateTo('/');
}, 30000);
},
}"
>
<a-typography-text code>
{{ JSON.stringify(unError, null, "\t") }}
</a-typography-text>
<a-typography-title :level="4"> Stack trace:</a-typography-title>
<a-typography-text>
<a-typography-text v-html="error.stack"></a-typography-text>
</a-typography-text>
</a-typography-paragraph>
</a-extract-style>
<a-typography-title> We ran into an issue.... :( <br /> </a-typography-title>
<a-typography-paragraph
style="font-size: 125%"
:copyable="{
text: copied,
tooltip: true,
onCopy: () => {
setTimeout(() => {
clearError({ redirect: '/' });
navigateTo('/');
}, 30000);
},
}"
>
<a-typography-text code>
{{ JSON.stringify(unError, null, "\t") }}
</a-typography-text>
<a-typography-title :level="4"> Stack trace: </a-typography-title>
<a-typography-text>
<a-typography-text v-html="error.stack"> </a-typography-text>
</a-typography-text>
</a-typography-paragraph>
</template>

View File

@ -1,6 +1,5 @@
<script lang="ts" setup>
import { Grid } from "ant-design-vue";
import { Grid, ItemType } from "ant-design-vue";
const bp = Grid.useBreakpoint();
const { data, status } = useAuth();
const itemMap = ref({
@ -47,31 +46,35 @@
:active-key="cur"
:key="data?.user?._id"
>
<a-menu-item key="home"> Home</a-menu-item>
<a-menu-item key="bands"> Bands</a-menu-item>
<a-menu-item key="authors"> Authors</a-menu-item>
<a-menu-item key="home"> Home </a-menu-item>
<a-menu-item key="bands"> Bands </a-menu-item>
<a-menu-item key="authors"> Authors </a-menu-item>
<a-menu-item key="forum"> Message Board</a-menu-item>
<a-sub-menu :disabled="!data?.user" v-if="!!data?.user" title="My Stuff" key="group/my-stuff">
<a-menu-item key="account"> Account</a-menu-item>
<a-menu-item key="edit-profile"> Edit Profile</a-menu-item>
<a-menu-item key="profile"> View Profile</a-menu-item>
<a-menu-item key="stories"> Stories</a-menu-item>
<a-menu-item key="drafts"> Drafts</a-menu-item>
<a-menu-item key="reviews"> Manage Reviews</a-menu-item>
<a-menu-item key="messages"> Private Messages</a-menu-item>
<a-menu-item key="account"> Account </a-menu-item>
<a-menu-item key="edit-profile"> Edit Profile </a-menu-item>
<a-menu-item key="profile"> View Profile </a-menu-item>
<a-menu-item key="stories"> Stories </a-menu-item>
<a-menu-item key="drafts"> Drafts </a-menu-item>
<a-menu-item key="reviews"> Manage Reviews </a-menu-item>
<a-menu-item key="messages"> Private Messages </a-menu-item>
</a-sub-menu>
<a-menu-item key="admin" v-if="data?.user?.profile.isAdmin || false"> Admin</a-menu-item>
<a-menu-item key="logout" v-if="!!data?.user"> Logout</a-menu-item>
<a-menu-item key="admin" v-if="data?.user?.profile.isAdmin || false"> Admin </a-menu-item>
<a-menu-item key="logout" v-if="!!data?.user"> Logout </a-menu-item>
</a-menu>
<a-button class="new-btn" type="primary" tooltip="Post a New Story" @click="() => navigateTo(`/new-story`)" v-if="data?.user">
<!-- <template #icon>
<div v-if="data?.user">
<nuxt-link to="/new-story">
<a-button type="primary" tooltip="Post a New Story">
<!-- <template #icon>
</template> -->
<icon istyle="regular" name="file-plus" />
<span style="margin-left: 0.5em"> Post a New Story </span>
</a-button>
<icon istyle="regular" name="file-plus" />
<span style="margin-left: 0.5em"> Post a New Story </span>
</a-button>
</nuxt-link>
</div>
<div class="acbut" v-if="!data?.user">
<a-button size="large" @click="() => navigateTo('/auth/login')"> Login</a-button>
<a-button size="large" type="primary" @click="() => navigateTo('/auth/register')"> Register</a-button>
<a-button size="large" @click="() => navigateTo('/auth/login')"> Login </a-button>
<a-button size="large" type="primary" @click="() => navigateTo('/auth/register')"> Register </a-button>
</div>
</div>
</template>
@ -98,11 +101,4 @@
flex-grow: 1.2;
justify-content: stretch;
}
@media (min-width: 768px) {
.new-btn {
align-self: self-end;
margin-top: 1em;
}
}
</style>

View File

@ -4,6 +4,7 @@
import icon from "~/components/icon.vue";
const story = inject<SingleChapterResult | null>("story");
console.log("storyyy--info", story);
const dark = inject<Ref<boolean>>("dark");
</script>
<template>

1
index.d.ts vendored
View File

@ -1 +0,0 @@
/// <reference types="typings/node-ext.d.ts">

View File

@ -14,7 +14,7 @@ export const storyMiddleware = defineNuxtRouteMiddleware(async (to, from) => {
console.log("to n from", to, from, data);
const { data: story, error } = await useApiFetch<SingleChapterResult>(to.path);
if (error.value) {
if (error.value.message.toLocaleLowerCase() == "unauthenticated" || error.value.statusCode == "403") {
if (error.value.message.toLocaleLowerCase() == "unauthenticated") {
return navigateTo("/auth/login");
}
return showError(error.value);

View File

@ -1,10 +1,9 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
import { IUser } from "@models/user";
import { render } from "vue";
import { rc } from "./lib/server/constants";
import { defineNuxtConfig } from "nuxt/config";
import { fileURLToPath } from "url";
import { StorageMounts } from "nitropack";
import { uri } from "./lib/dbconfig";
const cac = {
isr: true,
@ -142,11 +141,7 @@ export default defineNuxtConfig({
runtimeConfig: rc,
typescript: {
tsConfig: {
exclude: ["./.nuxt/types/auth.d.ts", "../**/node_modules/next/**/*.d.ts"],
compilerOptions: {
typeRoots: ["typings/**/*.d.ts"],
types: ["typings/node-ext.d.ts"],
},
exclude: ["./.nuxt/types/auth.d.ts"],
},
},
imports: {

View File

@ -1,7 +1,6 @@
<script lang="ts" setup>
import { reactive } from "vue";
import { notification } from "ant-design-vue";
interface FormState {
username: string;
password: string;
@ -16,26 +15,23 @@
useHead({
title: "Log In",
});
const loadRef = ref<boolean>(false);
const formState = reactive<FormState>({
username: "",
password: "",
});
const darkRef = inject<Ref<boolean>>("dark")!;
const darkRef = inject<Ref<boolean>>("dark");
const onFinish = async (values: any) => {
const { signIn } = useAuth();
try {
loadRef.value = true;
await signIn(values, { redirect: true, callbackUrl: "/" });
const { data } = useAuth();
darkRef!.value = data.value?.user?.profile.nightMode || false;
if (darkRef!.value) document.body.dataset.theme = "dark";
darkRef.value = data.value.user.profile.nightMode;
if (darkRef.value) document.body.dataset.theme = "dark";
await navigateTo("/");
} catch (e: any) {
if (e.data) {
loadRef.value = false;
notification["error"]({
message: h("div", { innerHTML: e.data.message }),
});
@ -54,7 +50,7 @@
<a-form-item>
<a-row :justify="'center'" :align="'middle'">
<a-col>
<a-button :loading="loadRef" data-testid="login.submit" type="primary" html-type="submit">Log in</a-button>
<a-button data-testid="login.submit" type="primary" html-type="submit">Log in</a-button>
</a-col>
</a-row>
</a-form-item>

View File

@ -16,6 +16,7 @@
const rtr = useRoute();
const { data: story, error } = await useApiFetch<SingleChapterResult>(`/story/${rtr.params.id}/${rtr.params.cidx}`);
provide<SingleChapterResult | null>("story", story.value);
console.log("storyyy", story.value?.currentChapter);
console.log(rtr);
let dark = inject<boolean>("dark");
const and = computed(() => {

View File

@ -1,5 +1,5 @@
export default eventHandler((event) => {
let ahead = (getHeaders(event).authorization || getHeaders(event).Authorization || "")?.replace("Bearer ", "");
let ahead = (getHeaders(event).authorization || "")?.replace("Bearer ", "");
if (event.context.currentUser && ahead) {
return {
token: ahead,

View File

@ -1,26 +1,26 @@
import jwt from "jsonwebtoken";
import { IUser, User } from "@models/user";
import { log } from "@server/logger";
import { messages } from "@server/constants";
import { User } from "@models/user";
import { AccessToken } from "@models/oauth";
import { IJwt } from "@server/types/authstuff";
export default defineEventHandler(async (event) => {
let ahead = (getHeaders(event).authorization || getHeaders(event).Authorization || getCookie(event, "rockfic_cookie"))?.replace("Bearer ", "");
let ahead = (getHeaders(event).authorization || "")?.replace("Bearer ", "");
if (ahead) {
let toktok: any;
let user: IUser | null = null;
let toktok: jwt.JwtPayload;
try {
toktok = jwt.verify(ahead, useRuntimeConfig().jwt);
console.log(toktok);
if (toktok?.sub) {
user = await User.findById(toktok.sub as number)
.select("-password -auth -ipLog")
.exec();
} else if (toktok.id) {
user = await User.findById(toktok.id as number)
.select("-password -auth -ipLog")
.exec();
}
} catch (E) {
console.error(E);
} finally {
toktok = jwt.verify(ahead, useRuntimeConfig().jwt) as IJwt;
let user = await User.findById(toktok.id as number).exec();
if (user && toktok) event.context.currentUser = user;
} catch (e) {
const t = await AccessToken.findOne({ token: ahead });
if (!t)
throw createError({
statusCode: 401,
message: messages[401],
});
let user = await User.findById(t.userID);
if (user) event.context.currentUser = user;
}
}

View File

@ -8,22 +8,6 @@
"noImplicitThis": false,
"verbatimModuleSyntax": false,
"forceConsistentCasingInFileNames": false,
"allowSyntheticDefaultImports": true,
"types": [
"./typings/fuck-you.ts",
"./typings/*.d.ts"
],
"typeRoots": [
"typings/**/*.d.ts",
"typings"
]
"allowSyntheticDefaultImports": true
},
"exclude": [
"**/node_modules/next/**/*.d.ts"
],
"include": [
"typings/**/*.d.ts",
"typings/node-ext.d.ts",
"nuxt.config.ts"
]
}

View File

@ -1,7 +0,0 @@
declare global {
namespace NodeJS {
interface ProcessEnv {
NODE_ENV: ("development" | "staging" | "production" | "test") & (string & {});
}
}
}