mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-03-15 03:02:08 +00:00
feat: frontend i18n
This commit is contained in:
@@ -58,5 +58,12 @@
|
|||||||
"domainWarningTitle": "Invalid Domain",
|
"domainWarningTitle": "Invalid Domain",
|
||||||
"domainWarningSubtitle": "This instance is configured to be accessed from <code>{{appUrl}}</code>, but <code>{{currentUrl}}</code> is being used. If you proceed, you may encounter issues with authentication.",
|
"domainWarningSubtitle": "This instance is configured to be accessed from <code>{{appUrl}}</code>, but <code>{{currentUrl}}</code> is being used. If you proceed, you may encounter issues with authentication.",
|
||||||
"ignoreTitle": "Ignore",
|
"ignoreTitle": "Ignore",
|
||||||
"goToCorrectDomainTitle": "Go to correct domain"
|
"goToCorrectDomainTitle": "Go to correct domain",
|
||||||
|
"authorizeTitle": "Authorize",
|
||||||
|
"authorizeCardTitle": "Continue to {{app}}?",
|
||||||
|
"authorizeSubtitle": "Would you like to continue to this app? Please keep in mind that this app will have access to your email and other information.",
|
||||||
|
"authorizeLoadingTitle": "Loading...",
|
||||||
|
"authorizeLoadingSubtitle": "Please wait while we load the client information.",
|
||||||
|
"authorizeSuccessTitle": "Authorized",
|
||||||
|
"authorizeSuccessSubtitle": "You will be redirected to the app in a few seconds."
|
||||||
}
|
}
|
||||||
@@ -58,5 +58,12 @@
|
|||||||
"domainWarningTitle": "Invalid Domain",
|
"domainWarningTitle": "Invalid Domain",
|
||||||
"domainWarningSubtitle": "This instance is configured to be accessed from <code>{{appUrl}}</code>, but <code>{{currentUrl}}</code> is being used. If you proceed, you may encounter issues with authentication.",
|
"domainWarningSubtitle": "This instance is configured to be accessed from <code>{{appUrl}}</code>, but <code>{{currentUrl}}</code> is being used. If you proceed, you may encounter issues with authentication.",
|
||||||
"ignoreTitle": "Ignore",
|
"ignoreTitle": "Ignore",
|
||||||
"goToCorrectDomainTitle": "Go to correct domain"
|
"goToCorrectDomainTitle": "Go to correct domain",
|
||||||
|
"authorizeTitle": "Authorize",
|
||||||
|
"authorizeCardTitle": "Continue to {{app}}?",
|
||||||
|
"authorizeSubtitle": "Would you like to continue to this app? Please keep in mind that this app will have access to your email and other information.",
|
||||||
|
"authorizeLoadingTitle": "Loading...",
|
||||||
|
"authorizeLoadingSubtitle": "Please wait while we load the client information.",
|
||||||
|
"authorizeSuccessTitle": "Authorized",
|
||||||
|
"authorizeSuccessSubtitle": "You will be redirected to the app in a few seconds."
|
||||||
}
|
}
|
||||||
@@ -14,16 +14,19 @@ import { Button } from "@/components/ui/button";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { useOIDCParams } from "@/lib/hooks/oidc";
|
import { useOIDCParams } from "@/lib/hooks/oidc";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export const AuthorizePage = () => {
|
export const AuthorizePage = () => {
|
||||||
const { isLoggedIn } = useUserContext();
|
const { isLoggedIn } = useUserContext();
|
||||||
const { search } = useLocation();
|
const { search } = useLocation();
|
||||||
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const searchParams = new URLSearchParams(search);
|
const searchParams = new URLSearchParams(search);
|
||||||
const {
|
const {
|
||||||
values: props,
|
values: props,
|
||||||
missingParams,
|
missingParams,
|
||||||
|
isOidc,
|
||||||
compiled: compiledOIDCParams,
|
compiled: compiledOIDCParams,
|
||||||
} = useOIDCParams(searchParams);
|
} = useOIDCParams(searchParams);
|
||||||
|
|
||||||
@@ -34,6 +37,7 @@ export const AuthorizePage = () => {
|
|||||||
const data = await getOidcClientInfoScehma.parseAsync(await res.json());
|
const data = await getOidcClientInfoScehma.parseAsync(await res.json());
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
enabled: isOidc,
|
||||||
});
|
});
|
||||||
|
|
||||||
const authorizeMutation = useMutation({
|
const authorizeMutation = useMutation({
|
||||||
@@ -48,8 +52,8 @@ export const AuthorizePage = () => {
|
|||||||
},
|
},
|
||||||
mutationKey: ["authorize", props.client_id],
|
mutationKey: ["authorize", props.client_id],
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
toast.info("Authorized", {
|
toast.info(t("authorizeSuccessTitle"), {
|
||||||
description: "You will be soon redirected to your application",
|
description: t("authorizeSuccessSubtitle"),
|
||||||
});
|
});
|
||||||
window.location.replace(data.data.redirect_uri);
|
window.location.replace(data.data.redirect_uri);
|
||||||
},
|
},
|
||||||
@@ -77,10 +81,10 @@ export const AuthorizePage = () => {
|
|||||||
return (
|
return (
|
||||||
<Card className="min-w-xs sm:min-w-sm">
|
<Card className="min-w-xs sm:min-w-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-3xl">Loading...</CardTitle>
|
<CardTitle className="text-3xl">
|
||||||
<CardDescription>
|
{t("authorizeLoadingTitle")}
|
||||||
Please wait while we load the client information.
|
</CardTitle>
|
||||||
</CardDescription>
|
<CardDescription>{t("authorizeLoadingSubtitle")}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
@@ -99,26 +103,25 @@ export const AuthorizePage = () => {
|
|||||||
<Card className="min-w-xs sm:min-w-sm">
|
<Card className="min-w-xs sm:min-w-sm">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-3xl">
|
<CardTitle className="text-3xl">
|
||||||
Continue to {getClientInfo.data?.name || "Unknown"}?
|
{t("authorizeCardTitle", {
|
||||||
|
app: getClientInfo.data?.name || "Unknown",
|
||||||
|
})}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>{t("authorizeSubtitle")}</CardDescription>
|
||||||
Would you like to continue to this app? Please keep in mind that this
|
|
||||||
app will have access to your email and other information.
|
|
||||||
</CardDescription>
|
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardFooter className="flex flex-col items-stretch gap-2">
|
<CardFooter className="flex flex-col items-stretch gap-2">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => authorizeMutation.mutate()}
|
onClick={() => authorizeMutation.mutate()}
|
||||||
loading={authorizeMutation.isPending}
|
loading={authorizeMutation.isPending}
|
||||||
>
|
>
|
||||||
Authorize
|
{t("authorizeTitle")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => navigate("/")}
|
onClick={() => navigate("/")}
|
||||||
disabled={authorizeMutation.isPending}
|
disabled={authorizeMutation.isPending}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
>
|
>
|
||||||
Cancel
|
{t("cancelTitle")}
|
||||||
</Button>
|
</Button>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Reference in New Issue
Block a user