diff --git a/actions/providers/providers.ts b/actions/providers/providers.ts index 8c67196f92..200bc79bd6 100644 --- a/actions/providers/providers.ts +++ b/actions/providers/providers.ts @@ -48,7 +48,7 @@ export const getProviders = async ({ }; export const getProvider = async (formData: FormData) => { - // const session = await auth(); + const session = await auth(); const providerId = formData.get("id"); const keyServer = process.env.API_BASE_URL; @@ -58,6 +58,7 @@ export const getProvider = async (formData: FormData) => { const providers = await fetch(url.toString(), { headers: { Accept: "application/vnd.api+json", + Authorization: `Bearer ${session?.accessToken}`, }, }); const data = await providers.json(); @@ -71,7 +72,7 @@ export const getProvider = async (formData: FormData) => { }; export const updateProvider = async (formData: FormData) => { - // const session = await auth(); + const session = await auth(); const keyServer = process.env.API_BASE_URL; const providerId = formData.get("providerId"); @@ -85,6 +86,7 @@ export const updateProvider = async (formData: FormData) => { headers: { "Content-Type": "application/vnd.api+json", Accept: "application/vnd.api+json", + Authorization: `Bearer ${session?.accessToken}`, }, body: JSON.stringify({ data: { @@ -173,7 +175,7 @@ export const checkConnectionProvider = async (formData: FormData) => { }; export const deleteProvider = async (formData: FormData) => { - // const session = await auth(); + const session = await auth(); const keyServer = process.env.API_BASE_URL; const providerId = formData.get("id"); @@ -184,6 +186,7 @@ export const deleteProvider = async (formData: FormData) => { method: "DELETE", headers: { Accept: "application/vnd.api+json", + Authorization: `Bearer ${session?.accessToken}`, }, }); const data = await response.json(); @@ -196,7 +199,7 @@ export const deleteProvider = async (formData: FormData) => { } }; -export const getErrorMessage = (error: unknown): string => { +export const getErrorMessage = async (error: unknown): Promise => { let message: string; if (error instanceof Error) { diff --git a/app/(auth)/sign-in/page.tsx b/app/(auth)/sign-in/page.tsx index 0f8ebffd55..b5bd978029 100644 --- a/app/(auth)/sign-in/page.tsx +++ b/app/(auth)/sign-in/page.tsx @@ -1,4 +1,4 @@ -import { AuthForm } from "@/components/auth"; +import { AuthForm } from "@/components/auth/oss"; const SignIn = () => { return ; diff --git a/app/(auth)/sign-up/page.tsx b/app/(auth)/sign-up/page.tsx index 8f7954ba34..8e525507b8 100644 --- a/app/(auth)/sign-up/page.tsx +++ b/app/(auth)/sign-up/page.tsx @@ -1,4 +1,4 @@ -import { AuthForm } from "@/components/auth"; +import { AuthForm } from "@/components/auth/oss"; const SignUp = () => { return ; diff --git a/app/(prowler)/profile/page.tsx b/app/(prowler)/profile/page.tsx index 91fa4907f0..0cfb4f8ab2 100644 --- a/app/(prowler)/profile/page.tsx +++ b/app/(prowler)/profile/page.tsx @@ -15,7 +15,7 @@ export default async function Profile() { } // const user = await getUserByMe(); - // console.log("user", user); + return ( <>
diff --git a/app/(prowler)/providers/page.tsx b/app/(prowler)/providers/page.tsx index a5cb092664..b999671859 100644 --- a/app/(prowler)/providers/page.tsx +++ b/app/(prowler)/providers/page.tsx @@ -24,7 +24,7 @@ export default async function Providers({
- + diff --git a/auth.config.ts b/auth.config.ts index 556c7d40c0..4639f8bf37 100644 --- a/auth.config.ts +++ b/auth.config.ts @@ -124,7 +124,7 @@ export const authConfig = { token.accessToken as string, ) as CustomJwtPayload; // eslint-disable-next-line no-console - console.log("decodedToken", decodedToken); + // console.log("decodedToken", decodedToken); token.accessTokenExpires = (decodedToken.exp as number) * 1000; token.user_id = decodedToken.user_id; token.tenant_id = decodedToken.tenant_id; @@ -150,11 +150,11 @@ export const authConfig = { } // eslint-disable-next-line no-console - console.log( - "Access token expires", - token.accessTokenExpires, - new Date(Number(token.accessTokenExpires)), - ); + // console.log( + // "Access token expires", + // token.accessTokenExpires, + // new Date(Number(token.accessTokenExpires)), + // ); // If the access token is not expired, return the token if ( diff --git a/components/auth/auth-form.tsx b/components/auth/oss/auth-form.tsx similarity index 87% rename from components/auth/auth-form.tsx rename to components/auth/oss/auth-form.tsx index 038a34dd6d..451e043c0b 100644 --- a/components/auth/auth-form.tsx +++ b/components/auth/oss/auth-form.tsx @@ -4,12 +4,16 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { Icon } from "@iconify/react"; import { Button, Checkbox, Divider, Link } from "@nextui-org/react"; import { useRouter } from "next/navigation"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { useFormState } from "react-dom"; import { useForm } from "react-hook-form"; import { z } from "zod"; import { authenticate, createNewUser } from "@/actions/auth"; +import { NotificationIcon, ProwlerExtended } from "@/components/icons"; +import { ThemeSwitch } from "@/components/ThemeSwitch"; +import { useToast } from "@/components/ui"; +import { CustomButton, CustomInput } from "@/components/ui/custom"; import { Form, FormControl, @@ -18,11 +22,6 @@ import { } from "@/components/ui/form"; import { ApiError, authFormSchema } from "@/types"; -import { NotificationIcon, ProwlerExtended } from "../icons"; -import { ThemeSwitch } from "../ThemeSwitch"; -import { CustomButton, CustomInput } from "../ui/custom"; -import { useToast } from "../ui/toast"; - export const AuthForm = ({ type }: { type: string }) => { const formSchema = authFormSchema(type); const router = useRouter(); @@ -42,11 +41,9 @@ export const AuthForm = ({ type }: { type: string }) => { }); const [state, dispatch] = useFormState(authenticate, undefined); - + const [isLoading, setIsLoading] = useState(false); const { toast } = useToast(); - const isLoading = form.formState.isSubmitting; - useEffect(() => { if (state?.message === "Success") { router.push("/"); @@ -55,13 +52,17 @@ export const AuthForm = ({ type }: { type: string }) => { const onSubmit = async (data: z.infer) => { if (type === "sign-in") { + setIsLoading(true); dispatch({ email: data.email.toLowerCase(), password: data.password, }); + setIsLoading(false); } if (type === "sign-up") { + setIsLoading(true); const newUser = await createNewUser(data); + setIsLoading(false); if (!newUser.errors) { router.push("/sign-in"); @@ -111,13 +112,15 @@ export const AuthForm = ({ type }: { type: string }) => { return (
{/* Auth Form */} -
- {/* Prowler Logo */} -
- -
+
+ {/* Background Pattern */} +
-
+
+ {/* Prowler Logo */} +
+ +

{type === "sign-in" ? "Sign In" : "Sign Up"} @@ -286,22 +289,6 @@ export const AuthForm = ({ type }: { type: string }) => { )}

- -
-
-

- Open Source Security Platform -

-
-
); }; diff --git a/components/auth/index.ts b/components/auth/oss/index.ts similarity index 100% rename from components/auth/index.ts rename to components/auth/oss/index.ts diff --git a/components/filters/data-filters.ts b/components/filters/data-filters.ts index 9aea8e9dd3..df1e01cea0 100644 --- a/components/filters/data-filters.ts +++ b/components/filters/data-filters.ts @@ -1,9 +1,4 @@ export const filtersProviders = [ - { - key: "provider__in", - labelCheckboxGroup: "Select a Provider", - values: ["aws", "gcp", "azure", "kubernetes"], - }, { key: "connected", labelCheckboxGroup: "Connection", diff --git a/tailwind.config.js b/tailwind.config.js index 608551bb96..31bdbfd39e 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -20,36 +20,34 @@ module.exports = { extend: { colors: { prowler: { - blue: { + theme: { midnight: "#030921", pale: "#f3fcff", - smoky: "#7b8390", - }, - grey: { - medium: "#353a4d", - light: "#868994", - }, - green: { - DEFAULT: "#9FD655", - medium: "#09BF3D", - }, - theme: { green: "#6af400", purple: "#5001d0", coral: "#ff5356", orange: "#f69000", yellow: "#ffdf16", }, - dark: { - DEFAULT: "#0E1117", - 700: "#151B23", - 400: "#262C36", - title: "#E2E8F0", - text: "#94a3b8" /* primary default for dark mode */, + blue: { + 800: "#1e293bff", }, - light: { - title: "#1e293bff", - text: "#64748b" /* primary default for light mode */, + grey: { + medium: "#353a4d", + light: "#868994", + 600: "#64748b", + }, + green: { + DEFAULT: "#9FD655", + medium: "#09BF3D", + }, + black: { + DEFAULT: "#000", + 900: "#18181A", + }, + white: { + DEFAULT: "#FFF", + 900: "#18181A", }, }, system: {