fix and update
This commit is contained in:
@@ -13,7 +13,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/u
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { OAuthClient, OAuthScope, apiFetch } from '@/lib/api';
|
||||
import { getAdminLandingPath } from '@/lib/admin-access';
|
||||
import { buildAuthorizeUrl, buildOAuthEndpoints, resolveOAuthApiBase } from '@/lib/oauth-url';
|
||||
import { buildAuthorizeUrl, buildOAuthEndpoints, resolveFrontendBase, resolveOAuthApiBase } from '@/lib/oauth-url';
|
||||
|
||||
export default function AdminOAuthPage() {
|
||||
const router = useRouter();
|
||||
@@ -26,16 +26,22 @@ export default function AdminOAuthPage() {
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const [selectedClient, setSelectedClient] = useState<OAuthClient | null>(null);
|
||||
const [secretDialog, setSecretDialog] = useState<{ clientId: string; clientSecret: string } | null>(null);
|
||||
const [oauthApiBase, setOauthApiBase] = useState('http://localhost:3000');
|
||||
const [oauthApiBase, setOauthApiBase] = useState('http://localhost:3002/idp-api');
|
||||
const [frontendBase, setFrontendBase] = useState('http://localhost:3002');
|
||||
const [projectName, setProjectName] = useState('MVK ID');
|
||||
const [form, setForm] = useState({ name: '', redirectUris: '', type: 'CONFIDENTIAL', selectedScopes: ['openid', 'profile', 'email'] as string[] });
|
||||
|
||||
const oauthEndpoints = useMemo(() => buildOAuthEndpoints(oauthApiBase), [oauthApiBase]);
|
||||
const oauthEndpoints = useMemo(() => buildOAuthEndpoints(oauthApiBase, frontendBase), [oauthApiBase, frontendBase]);
|
||||
|
||||
const loadPublicSettings = useCallback(async () => {
|
||||
try {
|
||||
const response = await apiFetch<{ settings: Array<{ key: string; value: string }> }>('/settings/public');
|
||||
const settings = Object.fromEntries((response.settings ?? []).map((item) => [item.key, item.value]));
|
||||
setOauthApiBase(resolveOAuthApiBase(settings));
|
||||
setFrontendBase(resolveFrontendBase(settings));
|
||||
if (settings.PROJECT_NAME?.trim()) {
|
||||
setProjectName(settings.PROJECT_NAME.trim());
|
||||
}
|
||||
} catch {
|
||||
// оставляем fallback
|
||||
}
|
||||
@@ -182,11 +188,20 @@ export default function AdminOAuthPage() {
|
||||
<p className="text-sm text-[#667085]">
|
||||
Issuer: <code className="rounded bg-[#f4f5f8] px-1.5 py-0.5 text-xs">{oauthEndpoints.issuer}</code>
|
||||
{' · '}
|
||||
Frontend: <code className="rounded bg-[#f4f5f8] px-1.5 py-0.5 text-xs">{frontendBase}</code>
|
||||
{' · '}
|
||||
<a href={oauthEndpoints.openIdConfigurationUrl} target="_blank" rel="noreferrer" className="inline-flex items-center gap-1 text-[#1d4ed8] hover:underline">
|
||||
OpenID Configuration
|
||||
<ExternalLink className="h-3.5 w-3.5" />
|
||||
</a>
|
||||
</p>
|
||||
<p className="mt-1 text-xs text-[#667085]">
|
||||
One Tap Login настраивается в{' '}
|
||||
<a href="/admin/settings" className="text-[#1d4ed8] hover:underline">
|
||||
системных настройках
|
||||
</a>{' '}
|
||||
(PUBLIC_API_URL, PUBLIC_FRONTEND_URL, ONE_TAP_ENABLED).
|
||||
</p>
|
||||
</div>
|
||||
<Button onClick={() => setDialogOpen(true)} disabled={!user?.canManageOAuth}>
|
||||
<Plus className="h-4 w-4" />
|
||||
@@ -244,6 +259,8 @@ export default function AdminOAuthPage() {
|
||||
<OAuthClientDetailDialog
|
||||
client={selectedClient}
|
||||
endpoints={oauthEndpoints}
|
||||
frontendBase={frontendBase}
|
||||
projectName={projectName}
|
||||
open={Boolean(selectedClient)}
|
||||
onOpenChange={(open) => !open && setSelectedClient(null)}
|
||||
onCopy={copyText}
|
||||
|
||||
Reference in New Issue
Block a user