add change redirect uri from oauth

This commit is contained in:
lendry
2026-06-26 09:36:25 +03:00
parent 971d10abf6
commit c3b2eb4a50
2 changed files with 79 additions and 3 deletions

View File

@@ -107,6 +107,29 @@ export default function AdminOAuthPage() {
}
}
async function handleSaveRedirectUris(client: OAuthClient, redirectUris: string[]) {
if (!token) return;
if (!redirectUris.length) {
showToast('Укажите хотя бы один redirect URI');
return;
}
try {
const updated = await apiFetch<OAuthClient>(`/admin/rbac/oauth-clients/${client.clientId}`, {
method: 'PATCH',
body: JSON.stringify({ redirectUris })
}, token);
showToast('Redirect URI обновлены');
setSelectedClient((current) =>
current?.clientId === client.clientId
? { ...current, redirectUris: updated.redirectUris ?? redirectUris }
: current
);
await loadData();
} catch (error) {
showToast(error instanceof Error ? error.message : 'Не удалось сохранить redirect URI');
}
}
async function handleRotateSecret(clientId: string) {
if (!token) return;
try {
@@ -227,6 +250,7 @@ export default function AdminOAuthPage() {
onRotateSecret={(clientId) => void handleRotateSecret(clientId)}
onToggleActive={(client) => void handleToggleActive(client)}
onDelete={(client) => void handleDeleteClient(client)}
onSaveRedirectUris={handleSaveRedirectUris}
/>
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>