change public app name for oauth
This commit is contained in:
@@ -6,11 +6,13 @@ import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { CheckCircle2, Loader2, ShieldCheck } from 'lucide-react';
|
||||
import { BrandLogo } from '@/components/id/brand-logo';
|
||||
import { useAuth } from '@/components/id/auth-provider';
|
||||
import { usePublicSettings } from '@/components/id/public-settings-provider';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
approveOAuthAuthorization,
|
||||
checkOAuthConsent,
|
||||
fetchAuthSession,
|
||||
fetchOAuthClientPublicInfo,
|
||||
type OAuthConsentCheckResponse
|
||||
} from '@/lib/api';
|
||||
|
||||
@@ -26,11 +28,13 @@ function OAuthAuthorizeContent() {
|
||||
const searchParams = useSearchParams();
|
||||
const router = useRouter();
|
||||
const { user, token, isPinLocked, isLoading } = useAuth();
|
||||
const { projectName } = usePublicSettings();
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [checkingConsent, setCheckingConsent] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [sessionChecked, setSessionChecked] = useState(false);
|
||||
const [consentInfo, setConsentInfo] = useState<OAuthConsentCheckResponse | null>(null);
|
||||
const [clientName, setClientName] = useState<string | null>(null);
|
||||
const autoApproveStartedRef = useRef(false);
|
||||
|
||||
const oauthQuery = useMemo(() => buildOAuthQuery(searchParams), [searchParams]);
|
||||
@@ -42,7 +46,22 @@ function OAuthAuthorizeContent() {
|
||||
|
||||
const returnUrl = useMemo(() => `/auth/oauth/authorize?${oauthQuery.toString()}`, [oauthQuery]);
|
||||
|
||||
const clientLabel = consentInfo?.client?.name ?? clientId ?? 'Приложение';
|
||||
const clientLabel = clientName ?? consentInfo?.client?.name ?? 'Приложение';
|
||||
|
||||
useEffect(() => {
|
||||
if (!clientId) return;
|
||||
let cancelled = false;
|
||||
void fetchOAuthClientPublicInfo(clientId)
|
||||
.then((info) => {
|
||||
if (!cancelled && info.name.trim()) {
|
||||
setClientName(info.name.trim());
|
||||
}
|
||||
})
|
||||
.catch(() => undefined);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [clientId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!searchParams.has('userId')) return;
|
||||
@@ -107,6 +126,9 @@ function OAuthAuthorizeContent() {
|
||||
.then((result) => {
|
||||
if (cancelled) return;
|
||||
setConsentInfo(result);
|
||||
if (result.client?.name?.trim()) {
|
||||
setClientName(result.client.name.trim());
|
||||
}
|
||||
if (result.granted && !autoApproveStartedRef.current) {
|
||||
autoApproveStartedRef.current = true;
|
||||
void approve();
|
||||
@@ -193,7 +215,7 @@ function OAuthAuthorizeContent() {
|
||||
</div>
|
||||
<h1 className="text-2xl font-semibold">Разрешить доступ?</h1>
|
||||
<p className="mt-2 text-sm leading-relaxed text-[#667085]">
|
||||
Приложение <span className="font-medium text-[#1f2430]">{clientLabel}</span> запрашивает доступ к данным вашего аккаунта Lendry ID.
|
||||
Приложение <span className="font-medium text-[#1f2430]">{clientLabel}</span> запрашивает доступ к данным вашего аккаунта {projectName}.
|
||||
</p>
|
||||
<div className="mt-4 space-y-3 rounded-2xl bg-[#f4f5f8] p-4 text-sm">
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user