diff --git a/.env b/.env index c22d1734..c1e19f61 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -VERSION=1.4.0 \ No newline at end of file +VERSION=1.5.0 \ No newline at end of file diff --git a/src/ui/Admin/AdminSettings.tsx b/src/ui/Admin/AdminSettings.tsx index 718d406c..bece9c0a 100644 --- a/src/ui/Admin/AdminSettings.tsx +++ b/src/ui/Admin/AdminSettings.tsx @@ -16,7 +16,6 @@ import { TableRow, } from "@/components/ui/table.tsx"; import {Shield, Trash2, Users} from "lucide-react"; -import {toast} from "sonner"; import { getOIDCConfig, getRegistrationAllowed, @@ -53,11 +52,11 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React. token_url: '', identifier_path: 'sub', name_path: 'name', - scopes: 'openid email profile', - userinfo_url: '' + scopes: 'openid email profile' }); const [oidcLoading, setOidcLoading] = React.useState(false); const [oidcError, setOidcError] = React.useState(null); + const [oidcSuccess, setOidcSuccess] = React.useState(null); const [users, setUsers] = React.useState(null); + const [makeAdminSuccess, setMakeAdminSuccess] = React.useState(null); React.useEffect(() => { const jwt = getCookie("jwt"); @@ -120,6 +120,7 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React. e.preventDefault(); setOidcLoading(true); setOidcError(null); + setOidcSuccess(null); const required = ['client_id', 'client_secret', 'issuer_url', 'authorization_url', 'token_url']; const missing = required.filter(f => !oidcConfig[f as keyof typeof oidcConfig]); @@ -132,7 +133,7 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React. const jwt = getCookie("jwt"); try { await updateOIDCConfig(oidcConfig); - toast.success("OIDC configuration updated successfully!"); + setOidcSuccess("OIDC configuration updated successfully!"); } catch (err: any) { setOidcError(err?.response?.data?.error || "Failed to update OIDC configuration"); } finally { @@ -144,15 +145,16 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React. setOidcConfig(prev => ({...prev, [field]: value})); }; - const handleMakeUserAdmin = async (e: React.FormEvent) => { + const makeUserAdmin = async (e: React.FormEvent) => { e.preventDefault(); if (!newAdminUsername.trim()) return; setMakeAdminLoading(true); setMakeAdminError(null); + setMakeAdminSuccess(null); const jwt = getCookie("jwt"); try { await makeUserAdmin(newAdminUsername.trim()); - toast.success(`User ${newAdminUsername} is now an admin`); + setMakeAdminSuccess(`User ${newAdminUsername} is now an admin`); setNewAdminUsername(""); fetchUsers(); } catch (err: any) { @@ -162,29 +164,23 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React. } }; - const handleRemoveAdminStatus = async (username: string) => { + const removeAdminStatus = async (username: string) => { if (!confirm(`Remove admin status from ${username}?`)) return; const jwt = getCookie("jwt"); try { await removeAdminStatus(username); - toast.success(`Admin status removed from ${username}`); fetchUsers(); - } catch (err: any) { - console.error('Failed to remove admin status:', err); - toast.error('Failed to remove admin status'); + } catch { } }; - const handleDeleteUser = async (username: string) => { + const deleteUser = async (username: string) => { if (!confirm(`Delete user ${username}? This cannot be undone.`)) return; const jwt = getCookie("jwt"); try { await deleteUser(username); - toast.success(`User ${username} deleted successfully`); fetchUsers(); - } catch (err: any) { - console.error('Failed to delete user:', err); - toast.error('Failed to delete user'); + } catch { } }; @@ -300,15 +296,9 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React.
handleOIDCConfigChange('scopes', e.target.value)} + onChange={(e) => handleOIDCConfigChange('scopes', (e.target as HTMLInputElement).value)} placeholder="openid email profile" required/>
-
- - handleOIDCConfigChange('userinfo_url', e.target.value)} - placeholder="https://your-provider.com/application/o/userinfo/"/> -
@@ -320,10 +310,16 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React. token_url: '', identifier_path: 'sub', name_path: 'name', - scopes: 'openid email profile', - userinfo_url: '' + scopes: 'openid email profile' })}>Reset
+ + {oidcSuccess && ( + + Success + {oidcSuccess} + + )} @@ -361,7 +357,7 @@ export function AdminSettings({isTopbarOpen = true}: AdminSettingsProps): React. className="px-4">{user.is_oidc ? "External" : "Local"}