mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-11 23:46:50 +00:00
more fixes
This commit is contained in:
@@ -3,7 +3,7 @@ import ValidateOidcToken from "./ValidateOidcToken";
|
||||
import { idp } from "@server/db/schemas";
|
||||
import db from "@server/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
export default async function Page(props: {
|
||||
params: Promise<{ orgId: string; idpId: string }>;
|
||||
@@ -14,6 +14,7 @@ export default async function Page(props: {
|
||||
}) {
|
||||
const params = await props.params;
|
||||
const searchParams = await props.searchParams;
|
||||
const t = await getTranslations();
|
||||
|
||||
const allCookies = await cookies();
|
||||
const stateCookie = allCookies.get("p_oidc_state")?.value;
|
||||
@@ -24,8 +25,6 @@ export default async function Page(props: {
|
||||
.from(idp)
|
||||
.where(eq(idp.idpId, parseInt(params.idpId!)));
|
||||
|
||||
const t = useTranslations();
|
||||
|
||||
if (!idpRes) {
|
||||
return <div>{t('idpErrorNotFound')}</div>;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ export default async function AuthLayout({ children }: AuthLayoutProps) {
|
||||
aria-label="GitHub"
|
||||
className="flex items-center space-x-2 whitespace-nowrap"
|
||||
>
|
||||
<span>Community Edition</span>
|
||||
<span>{t('communityEdition')}</span>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
|
||||
@@ -63,7 +63,7 @@ export default async function Page(props: {
|
||||
|
||||
{(!signUpDisabled || isInvite) && (
|
||||
<p className="text-center text-muted-foreground mt-4">
|
||||
Don't have an account?{" "}
|
||||
{t('authNoAccount')}{" "}
|
||||
<Link
|
||||
href={
|
||||
!redirectUrl
|
||||
|
||||
@@ -138,8 +138,8 @@ export default function ResetPasswordForm({
|
||||
} as RequestPasswordResetBody
|
||||
)
|
||||
.catch((e) => {
|
||||
setError(formatAxiosError(e, "An error occurred"));
|
||||
console.error("Failed to request reset:", e);
|
||||
setError(formatAxiosError(e, t('errorOccurred')));
|
||||
console.error(t('passwordErrorRequestReset'), e);
|
||||
setIsSubmitting(false);
|
||||
});
|
||||
|
||||
@@ -168,8 +168,8 @@ export default function ResetPasswordForm({
|
||||
} as ResetPasswordBody
|
||||
)
|
||||
.catch((e) => {
|
||||
setError(formatAxiosError(e, "An error occurred"));
|
||||
console.error("Failed to reset password:", e);
|
||||
setError(formatAxiosError(e, t('errorOccurred')));
|
||||
console.error(t('passwordErrorReset'), e);
|
||||
setIsSubmitting(false);
|
||||
});
|
||||
|
||||
@@ -185,7 +185,7 @@ export default function ResetPasswordForm({
|
||||
return;
|
||||
}
|
||||
|
||||
setSuccessMessage("Password reset successfully! Back to log in...");
|
||||
setSuccessMessage(t('passwordResetSuccess'));
|
||||
|
||||
setTimeout(() => {
|
||||
if (redirect) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { cache } from "react";
|
||||
import ResetPasswordForm from "./ResetPasswordForm";
|
||||
import Link from "next/link";
|
||||
import { cleanRedirect } from "@app/lib/cleanRedirect";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -18,6 +18,7 @@ export default async function Page(props: {
|
||||
const searchParams = await props.searchParams;
|
||||
const getUser = cache(verifySession);
|
||||
const user = await getUser();
|
||||
const t = await getTranslations();
|
||||
|
||||
if (user) {
|
||||
redirect("/");
|
||||
@@ -28,8 +29,6 @@ export default async function Page(props: {
|
||||
redirectUrl = cleanRedirect(searchParams.redirect);
|
||||
}
|
||||
|
||||
const t = useTranslations();
|
||||
|
||||
return (
|
||||
<>
|
||||
<ResetPasswordForm
|
||||
|
||||
@@ -102,7 +102,7 @@ export default function AccessToken({
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error checking access token", e);
|
||||
console.error(t('accessTokenError'), e);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ type ResourceAuthPortalProps = {
|
||||
|
||||
export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
|
||||
const router = useRouter();
|
||||
const t = useTranslations();
|
||||
|
||||
const getNumMethods = () => {
|
||||
let colLength = 0;
|
||||
@@ -171,8 +172,6 @@ export default function ResourceAuthPortal(props: ResourceAuthPortalProps) {
|
||||
return fullUrl.toString();
|
||||
}
|
||||
|
||||
const t = useTranslations();
|
||||
|
||||
const onWhitelistSubmit = (values: any) => {
|
||||
setLoadingLogin(true);
|
||||
api.post<AxiosResponse<AuthWithWhitelistResponse>>(
|
||||
|
||||
@@ -10,6 +10,7 @@ import Link from "next/link";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
export default async function ResourceNotFound() {
|
||||
|
||||
const t = useTranslations();
|
||||
|
||||
return (
|
||||
|
||||
@@ -87,7 +87,7 @@ export default function SignupForm({
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
setError(
|
||||
formatAxiosError(e, "An error occurred while signing up")
|
||||
formatAxiosError(e, t('signupError'))
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Mail } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { cache } from "react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -16,13 +16,12 @@ export default async function Page(props: {
|
||||
const searchParams = await props.searchParams;
|
||||
const getUser = cache(verifySession);
|
||||
const user = await getUser();
|
||||
const t = await getTranslations();
|
||||
|
||||
const env = pullEnv();
|
||||
|
||||
const isInvite = searchParams?.redirect?.includes("/invite");
|
||||
|
||||
const t = useTranslations();
|
||||
|
||||
if (env.flags.disableSignupWithoutInvite && !isInvite) {
|
||||
redirect("/");
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ export default function VerifyEmailForm({
|
||||
redirect,
|
||||
}: VerifyEmailFormProps) {
|
||||
const router = useRouter();
|
||||
const t = useTranslations();
|
||||
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [successMessage, setSuccessMessage] = useState<string | null>(null);
|
||||
@@ -72,8 +73,6 @@ export default function VerifyEmailForm({
|
||||
},
|
||||
});
|
||||
|
||||
const t = useTranslations();
|
||||
|
||||
async function onSubmit(data: z.infer<typeof FormSchema>) {
|
||||
setIsSubmitting(true);
|
||||
|
||||
@@ -82,15 +81,15 @@ export default function VerifyEmailForm({
|
||||
code: data.pin,
|
||||
})
|
||||
.catch((e) => {
|
||||
setError(formatAxiosError(e, "An error occurred"));
|
||||
console.error("Failed to verify email:", e);
|
||||
setError(formatAxiosError(e, t('errorOccurred')));
|
||||
console.error(t('emailErrorVerify'), e);
|
||||
setIsSubmitting(false);
|
||||
});
|
||||
|
||||
if (res && res.data?.data?.valid) {
|
||||
setError(null);
|
||||
setSuccessMessage(
|
||||
"Email successfully verified! Redirecting you..."
|
||||
t('emailVerified')
|
||||
);
|
||||
setTimeout(() => {
|
||||
if (redirect) {
|
||||
@@ -108,16 +107,16 @@ export default function VerifyEmailForm({
|
||||
setIsResending(true);
|
||||
|
||||
const res = await api.post("/auth/verify-email/request").catch((e) => {
|
||||
setError(formatAxiosError(e, "An error occurred"));
|
||||
console.error("Failed to resend verification code:", e);
|
||||
setError(formatAxiosError(e, t('errorOccurred')));
|
||||
console.error(t('verificationCodeErrorResend'), e);
|
||||
});
|
||||
|
||||
if (res) {
|
||||
setError(null);
|
||||
toast({
|
||||
variant: "default",
|
||||
title: "Verification code resent",
|
||||
description: "We've resent a verification code to your email address. Please check your inbox.",
|
||||
title: t('verificationCodeResend'),
|
||||
description: t('verificationCodeResendDescription'),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user