Many Changes

This commit is contained in:
2024-05-14 12:49:50 +02:00
parent a01b6bdbc2
commit f6eef1ded3
53 changed files with 636 additions and 579 deletions

View File

@@ -1,7 +1,7 @@
'use client'
import { ReactNode, useContext } from "react";
import { AuthContext, AuthProps } from "@/providers/providers";
import SomeServerSubComponent from "./serverContextUserTest";
import SomeServerSubComponent from "@/components/server/admin/serverContextUserTest";
interface Props {
children?: ReactNode;

View File

@@ -1,9 +1,8 @@
'use client'
import { authenticate } from "@/app/lib/actions";
import { serverAttemptAuthenticateUser } from "@/app/lib/actions";
import { AuthContext } from "@/providers/providers";
import { constructAPIUrl } from "@/util/Utils";
import { cookies } from "next/headers";
import { createContext, useState } from "react";
import { useFormState, useFormStatus } from "react-dom";
@@ -15,11 +14,7 @@ import { useFormState, useFormStatus } from "react-dom";
export default function LoginForm(){
const [loginResult, dispatch] = useFormState(authenticate, undefined);
// if(loginResult?.cookie && loginResult.cookie && loginResult.cookie['auth']){
// cookies().set('auth', loginResult.cookie['auth'])
// }
const [loginResult, dispatch] = useFormState(serverAttemptAuthenticateUser, undefined);
return (
<form className="bg-background-400 border-4 border-primary-500 drop-shadow-md w-fit p-3 rounded-lg flex flex-col gap-1" action={dispatch}>

View File

@@ -1,13 +1,14 @@
'use server'
import { cookies } from "next/headers";
// import { useState } from "react";
import LoginForm from "./loginForm";
import { koekValid } from "@/app/lib/actions";
import LoginForm from "@/components/client/admin/loginForm";
import AdminPanel from "@/components/client/admin/adminPanel";
import ClientAuthHandler from "@/components/client/admin/clientAuthHandler";
import { serverValidateSessionCookie } from "@/app/lib/actions";
import { constructAPIUrl } from "@/util/Utils";
import AdminPanel from "./adminPanel";
import { ReactNode } from "react";
import { AuthContext, AuthProps } from "@/providers/providers";
import ClientAuthHandler from "./clientAuthHandler";
interface Props {
@@ -17,10 +18,9 @@ interface Props {
} // We interfacing lads
export default async function AuthHandler(props: Props) {
const protoKoek = await cookies().get('auth')?.value;
const koek = decodeURIComponent(protoKoek?protoKoek:"");
const koek = decodeURIComponent(protoKoek ? protoKoek: "");
console.log("koekje:" + koek)
let p:AuthProps = {
test:"not pog"
@@ -41,7 +41,7 @@ export default async function AuthHandler(props: Props) {
return (
<div className="flex flex-row">
{!(koek && await koekValid(koek)) ? <LoginForm>{ }</LoginForm> : <ClientAuthHandler authProps={p}><section>{props.children}<div>signed in! :D</div></section></ClientAuthHandler>}
{!(koek && await serverValidateSessionCookie(koek)) ? <LoginForm>{ }</LoginForm> : <ClientAuthHandler authProps={p}><section>{props.children}<div>signed in! :D</div></section></ClientAuthHandler>}
</div>
);
}

View File

@@ -8,6 +8,8 @@ interface Props {
export default function SomeServerSubComponent(props:Props){
let { test, auth } = useContext(AuthContext);
return (
<span>{test}{JSON.stringify(auth)}</span>
);

View File

@@ -1,5 +1,5 @@
import Tagbar from "@/components/news/tagbar";
import styles from "./article-preview.module.css"
import Tagbar from "@/components/shared/news/tagbar";
import styles from "@/components/shared/news/article-preview.module.css"
import bg from "public/placeholder-square.png"
import { ReactNode } from "react"

View File

@@ -1,4 +1,4 @@
import Tagbar from "@/components/news/tagbar";
import Tagbar from "@/components/shared/news/tagbar";
import "/public/global.css"
import "@/app/index.css"
import styles from "./article.module.css"