0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): enforce SSOT for webhook signing key (#3909)

This commit is contained in:
Xiao Yijun 2023-05-28 09:22:15 +08:00 committed by GitHub
parent 2b409fcefe
commit a9c34cd0b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,4 @@
import { type Hook } from '@logto/schemas'; import { type Hook } from '@logto/schemas';
import { useState } from 'react';
import { FormProvider, useForm } from 'react-hook-form'; import { FormProvider, useForm } from 'react-hook-form';
import { toast } from 'react-hot-toast'; import { toast } from 'react-hot-toast';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -21,7 +20,6 @@ import TestWebhook from './components/TestWebhook';
function WebhookSettings() { function WebhookSettings() {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const { hook, isDeleting, onHookUpdated } = useOutletContext<WebhookDetailsOutletContext>(); const { hook, isDeleting, onHookUpdated } = useOutletContext<WebhookDetailsOutletContext>();
const [signingKey, setSigningKey] = useState(hook.signingKey);
const webhookFormData = webhookDetailsParser.toLocalForm(hook); const webhookFormData = webhookDetailsParser.toLocalForm(hook);
const formMethods = useForm<WebhookDetailsFormType>({ const formMethods = useForm<WebhookDetailsFormType>({
defaultValues: webhookFormData, defaultValues: webhookFormData,
@ -59,8 +57,10 @@ function WebhookSettings() {
<BasicWebhookForm /> <BasicWebhookForm />
<SigningKeyField <SigningKeyField
hookId={hook.id} hookId={hook.id}
signingKey={signingKey} signingKey={hook.signingKey}
onSigningKeyUpdated={setSigningKey} onSigningKeyUpdated={(signingKey) => {
onHookUpdated({ ...hook, signingKey });
}}
/> />
<CustomHeaderField /> <CustomHeaderField />
</FormCard> </FormCard>