some changes
All checks were successful
Deploy / deploy (ubuntu-latest, 2.44.0) (push) Successful in 1m23s
All checks were successful
Deploy / deploy (ubuntu-latest, 2.44.0) (push) Successful in 1m23s
This commit is contained in:
parent
cd15266740
commit
e376dbf8d2
@ -1,13 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import { ReactElement } from "react";
|
||||
import OnboardingForm from "@/components/dashboard/onboarding/onboarding-form";
|
||||
import OnboardingForm from "@/components/dashboard/user/onboarding/onboarding-form";
|
||||
import { useUserContext } from "@/app/provider/user-provider";
|
||||
import { UserState } from "@/app/store/user-store";
|
||||
import { User } from "@/app/types/user/user";
|
||||
import { hasFlag } from "@/lib/user";
|
||||
import { UserFlag } from "@/app/types/user/user-flag";
|
||||
import CompletedOnboarding from "@/components/dashboard/onboarding/completed-onboarding";
|
||||
import CompletedOnboarding from "@/components/dashboard/user/onboarding/completed-onboarding";
|
||||
|
||||
const OnboardingPage = (): ReactElement => {
|
||||
const user: User | undefined = useUserContext(
|
||||
|
@ -23,6 +23,7 @@ import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.share
|
||||
import DashboardLoader from "@/components/dashboard/loader";
|
||||
import { hasFlag } from "@/lib/user";
|
||||
import { UserFlag } from "@/app/types/user/user-flag";
|
||||
import EmailVerificationScreen from "@/components/dashboard/user/email-verification-screen";
|
||||
|
||||
/**
|
||||
* The provider that will provide user context to children.
|
||||
@ -33,9 +34,11 @@ import { UserFlag } from "@/app/types/user/user-flag";
|
||||
const UserProvider = ({ children }: { children: ReactNode }) => {
|
||||
const storeRef = useRef<UserStore>();
|
||||
const [authorized, setAuthorized] = useState<boolean>(false);
|
||||
const [emailVerified, setEmailVerified] = useState<boolean>(false);
|
||||
const cookies: Cookies = useCookies();
|
||||
const router: AppRouterInstance = useRouter();
|
||||
const path: string = usePathname();
|
||||
|
||||
if (!storeRef.current) {
|
||||
storeRef.current = createUserStore();
|
||||
}
|
||||
@ -66,6 +69,7 @@ const UserProvider = ({ children }: { children: ReactNode }) => {
|
||||
const user: User = data as User;
|
||||
storeRef.current?.getState().authorize(session, user);
|
||||
setAuthorized(true);
|
||||
setEmailVerified(hasFlag(user, UserFlag.EMAIL_VERIFIED));
|
||||
|
||||
// User has not yet completed onboarding
|
||||
if (
|
||||
@ -82,6 +86,13 @@ const UserProvider = ({ children }: { children: ReactNode }) => {
|
||||
|
||||
return (
|
||||
<UserContext.Provider value={storeRef.current}>
|
||||
{/*{authorized && emailVerified ? (*/}
|
||||
{/* children*/}
|
||||
{/*) : !authorized ? (*/}
|
||||
{/* <DashboardLoader />*/}
|
||||
{/*) : (*/}
|
||||
{/* <EmailVerificationScreen />*/}
|
||||
{/*)}*/}
|
||||
{authorized ? children : <DashboardLoader />}
|
||||
</UserContext.Provider>
|
||||
);
|
||||
|
@ -5,20 +5,25 @@ export enum UserFlag {
|
||||
/**
|
||||
* The user is disabled.
|
||||
*/
|
||||
DISABLED = 0,
|
||||
DISABLED = 1 << 0,
|
||||
|
||||
/**
|
||||
* The user's email has been verified.
|
||||
*/
|
||||
EMAIL_VERIFIED = 1 << 1,
|
||||
|
||||
/**
|
||||
* The user completed the onboarding process.
|
||||
*/
|
||||
COMPLETED_ONBOARDING = 1,
|
||||
COMPLETED_ONBOARDING = 1 << 2,
|
||||
|
||||
/**
|
||||
* The user has two-factor auth enabled.
|
||||
*/
|
||||
TFA_ENABLED = 2,
|
||||
TFA_ENABLED = 1 << 3,
|
||||
|
||||
/**
|
||||
* The user is an administrator.
|
||||
*/
|
||||
ADMINISTRATOR = 3,
|
||||
ADMINISTRATOR = 1 << 4,
|
||||
}
|
||||
|
34
src/components/dashboard/user/email-verification-screen.tsx
Normal file
34
src/components/dashboard/user/email-verification-screen.tsx
Normal file
@ -0,0 +1,34 @@
|
||||
"use client";
|
||||
|
||||
import { ReactElement, useState } from "react";
|
||||
import { User } from "@/app/types/user/user";
|
||||
import { useUserContext } from "@/app/provider/user-provider";
|
||||
import { UserState } from "@/app/store/user-store";
|
||||
|
||||
/**
|
||||
* The screen to verify your email.
|
||||
*
|
||||
* @return the screen jsx
|
||||
*/
|
||||
const EmailVerificationScreen = (): ReactElement => {
|
||||
const user: User | undefined = useUserContext(
|
||||
(state: UserState) => state.user
|
||||
);
|
||||
const [lastEmailSent, setLastEmailSent] = useState<Date>(new Date());
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex justify-center items-center">
|
||||
{/* Header */}
|
||||
<div className="flex flex-col gap-1 text-center items-center select-none pointer-events-none">
|
||||
<h1 className="text-3xl font-bold">Email Verification</h1>
|
||||
<p className="max-w-[25rem]">
|
||||
<span className="opacity-65">
|
||||
We have sent your verification code to the email
|
||||
</span>{" "}
|
||||
<span>{user?.email}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default EmailVerificationScreen;
|
Loading…
x
Reference in New Issue
Block a user