🐛 fix(auth): Update authentication configuration and localization strings

This commit is contained in:
web@ppanel
2025-02-08 23:58:03 +07:00
parent 3a3d2236e2
commit 47f2c5853c
48 changed files with 749 additions and 293 deletions
@@ -1,6 +1,6 @@
'use client';
import { getOAuthByPlatform, updateOAuthConfig } from '@/services/admin/system';
import { getAuthMethodConfig, updateAuthMethodConfig } from '@/services/admin/authMethod';
import { useQuery } from '@tanstack/react-query';
import { Label } from '@workspace/ui/components/label';
import { Switch } from '@workspace/ui/components/switch';
@@ -13,21 +13,21 @@ export default function Page() {
const t = useTranslations('github');
const { data, refetch } = useQuery({
queryKey: ['getOAuthByPlatform', 'github'],
queryKey: ['getAuthMethodConfig', 'github'],
queryFn: async () => {
const { data } = await getOAuthByPlatform({
platform: 'github',
const { data } = await getAuthMethodConfig({
method: 'github',
});
return data.data;
},
});
async function updateConfig(key: keyof API.UpdateOAuthConfig, value: unknown) {
async function updateConfig(key: keyof API.UpdataAuthMethodConfigRequest, value: unknown) {
try {
await updateOAuthConfig({
await updateAuthMethodConfig({
...data,
[key]: value,
} as API.UpdateOAuthConfig);
} as API.UpdataAuthMethodConfigRequest);
toast.success(t('saveSuccess'));
refetch();
} catch (error) {
@@ -93,8 +93,13 @@ export default function Page() {
<TableCell className='text-right'>
<EnhancedInput
placeholder='https://your-domain.com/v1/auth/oauth/callback/github'
value={data?.redirect}
onValueBlur={(value) => updateConfig('redirect', value)}
value={data?.config.redirect_url}
onValueBlur={(value) =>
updateConfig('config', {
...data?.config,
redirect_url: value,
})
}
/>
</TableCell>
</TableRow>