Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

feat(webui): account settings page for email & password

Sergey Kozyrenkoddb654651e3b
diff --git a/frontend/src/app.tsx b/frontend/src/app.tsx
index 012be1fb..16a156d6 100644
--- a/frontend/src/app.tsx
+++ b/frontend/src/app.tsx
@@ -45,6 +45,7 @@ const Resources = lazy(() => import('@/pages/resources/resources'));
const Template = lazy(() => import('@/pages/templates/template'));
const Templates = lazy(() => import('@/pages/templates/templates'));
const OAuthResult = lazy(() => import('@/pages/oauth-result'));
+const SettingsAccount = lazy(() => import('@/pages/settings/settings-account'));
const SettingsAPITokens = lazy(() => import('@/pages/settings/settings-api-tokens'));
const SettingsPrompt = lazy(() => import('@/pages/settings/settings-prompt'));
const SettingsPrompts = lazy(() => import('@/pages/settings/settings-prompts'));
@@ -205,6 +206,11 @@ const router = createBrowserRouter(
}
index
/>
+ <Route
+ element={<SettingsAccount />}
+ handle={routeTitles.account}
+ path="account"
+ />
<Route
element={<SettingsProviders />}
handle={routeTitles.providers}
diff --git a/frontend/src/components/layouts/main-sidebar.tsx b/frontend/src/components/layouts/main-sidebar.tsx
index b4051f5b..54e28a0b 100644
--- a/frontend/src/components/layouts/main-sidebar.tsx
+++ b/frontend/src/components/layouts/main-sidebar.tsx
@@ -17,14 +17,13 @@ import {
Sun,
UserIcon,
} from 'lucide-react';
-import { useMemo, useState } from 'react';
+import { useMemo } from 'react';
import { Link, useMatch, useParams } from 'react-router-dom';
import type { Flow } from '@/providers/sidebar-flows-provider';
import type { Theme } from '@/providers/theme-provider';
import Logo from '@/components/icons/logo';
-import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import {
DropdownMenu,
DropdownMenuContent,
@@ -48,7 +47,6 @@ import {
SidebarRail,
} from '@/components/ui/sidebar';
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
-import { ProfileDialog } from '@/features/authentication/profile-dialog';
import { useResourcesUpload } from '@/features/resources/use-resources-upload';
import { useTheme } from '@/hooks/use-theme';
import { useFavorites } from '@/providers/favorites-provider';
@@ -63,7 +61,6 @@ interface FlowMenuItemProps {
}
export function MainSidebar() {
- const [isProfileModalOpen, setIsProfileModalOpen] = useState(false);
const isDashboardActive = useMatch('/dashboard');
const isFlowsActive = useMatch('/flows/*');
const isTemplatesActive = useMatch('/templates/*');
@@ -358,9 +355,11 @@ export function MainSidebar() {
{user?.type === 'local' && (
<>
<DropdownMenuSeparator />
- <DropdownMenuItem onClick={() => setIsProfileModalOpen(true)}>
- <UserIcon className="mr-2 size-4" />
- My Profile
+ <DropdownMenuItem asChild>
+ <Link to="/settings/account">
+ <UserIcon className="mr-2 size-4" />
+ My Profile
+ </Link>
</DropdownMenuItem>
</>
)}
@@ -386,21 +385,6 @@ export function MainSidebar() {
type="file"
{...resourcesUpload.fileInputProps}
/>
-
- <Dialog
- onOpenChange={setIsProfileModalOpen}
- open={isProfileModalOpen}
- >
- <DialogContent className="sm:max-w-[425px]">
- <DialogHeader>
- <DialogTitle>My Profile</DialogTitle>
- </DialogHeader>
- <ProfileDialog
- onCancel={() => setIsProfileModalOpen(false)}
- onSuccess={() => setIsProfileModalOpen(false)}
- />
- </DialogContent>
- </Dialog>
</Sidebar>
);
}
diff --git a/frontend/src/components/layouts/settings-layout.tsx b/frontend/src/components/layouts/settings-layout.tsx
index 64f3deb1..5d584264 100644
--- a/frontend/src/components/layouts/settings-layout.tsx
+++ b/frontend/src/components/layouts/settings-layout.tsx
@@ -1,4 +1,4 @@
-import { ArrowLeft, FileText, Key, Plug, Settings as SettingsIcon } from 'lucide-react';
+import { ArrowLeft, FileText, Key, Plug, Settings as SettingsIcon, User } from 'lucide-react';
import { useMemo } from 'react';
import { NavLink, Outlet, useLocation, useParams } from 'react-router-dom';
@@ -17,11 +17,12 @@ import {
SidebarProvider,
SidebarTrigger,
} from '@/components/ui/sidebar';
+import { useUser } from '@/providers/user-provider';
export interface MenuItem {
icon?: React.ReactNode;
id: string;
- isActive?: boolean;
+ isLocalOnly?: boolean;
path: string;
title: string;
}
@@ -31,6 +32,13 @@ interface SettingsSidebarMenuItemProps {
}
const menuItems: readonly MenuItem[] = [
+ {
+ icon: <User className="size-4" />,
+ id: 'account',
+ isLocalOnly: true,
+ path: '/settings/account',
+ title: 'Account',
+ },
{
icon: <Plug className="size-4" />,
id: 'providers',
@@ -108,6 +116,10 @@ function SettingsLayout() {
}
function SettingsSidebar() {
+ const { authInfo } = useUser();
+ const isLocal = authInfo?.user?.type === 'local';
+ const visibleItems = menuItems.filter((item) => !item.isLocalOnly || isLocal);
+
return (
<Sidebar collapsible="icon">
<SidebarHeader>
@@ -126,7 +138,7 @@ function SettingsSidebar() {
<SidebarGroup>
<SidebarGroupContent>
<SidebarMenu>
- {menuItems.map((item) => (
+ {visibleItems.map((item) => (
<SettingsSidebarMenuItem
item={item}
key={item.id}
diff --git a/frontend/src/components/ui/input-password.tsx b/frontend/src/components/ui/input-password.tsx
new file mode 100644
index 00000000..1c7b3d3f
--- /dev/null
+++ b/frontend/src/components/ui/input-password.tsx
@@ -0,0 +1,31 @@
+import { Eye, EyeOff } from 'lucide-react';
+import * as React from 'react';
+
+import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@/components/ui/input-group';
+
+export type InputPasswordProps = Omit<React.ComponentProps<typeof InputGroupInput>, 'type'>;
+
+function InputPassword(props: InputPasswordProps) {
+ const [visible, setVisible] = React.useState(false);
+
+ return (
+ <InputGroup>
+ <InputGroupInput
+ {...props}
+ type={visible ? 'text' : 'password'}
+ />
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ aria-label={visible ? 'Hide password' : 'Show password'}
+ onClick={() => setVisible((prev) => !prev)}
+ size="icon-sm"
+ tabIndex={-1}
+ >
+ {visible ? <EyeOff /> : <Eye />}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ );
+}
+
+export { InputPassword };
diff --git a/frontend/src/features/authentication/email-change-form.test.tsx b/frontend/src/features/authentication/email-change-form.test.tsx
new file mode 100644
index 00000000..12b8f640
--- /dev/null
+++ b/frontend/src/features/authentication/email-change-form.test.tsx
@@ -0,0 +1,66 @@
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+const { put, refreshAuthInfo } = vi.hoisted(() => ({
+ put: vi.fn(),
+ refreshAuthInfo: vi.fn().mockResolvedValue(undefined),
+}));
+
+// Keep the pure helpers (`getApiErrorCode`, `getApiErrorMessage`) real — only the network call is stubbed.
+vi.mock('@/lib/axios', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('@/lib/axios')>();
+
+ return { ...actual, api: { ...actual.api, put } };
+});
+
+vi.mock('@/providers/user-provider', () => ({
+ useUser: () => ({ authInfo: { user: { mail: '[email protected]' } }, refreshAuthInfo }),
+}));
+
+vi.mock('sonner', () => ({ toast: { error: vi.fn(), success: vi.fn() } }));
+
+import { EmailChangeForm } from './email-change-form';
+
+const apiError = (code: string, msg: string) => ({ response: { data: { code, msg, status: 'error' } } });
+
+beforeEach(() => {
+ put.mockReset().mockResolvedValue({ status: 'success' });
+ refreshAuthInfo.mockClear();
+});
+
+describe('EmailChangeForm', () => {
+ it('shows the current email in a label-associated disabled field', () => {
+ render(<EmailChangeForm />);
+
+ const current = screen.getByLabelText('Current Email') as HTMLInputElement;
+ expect(current).toBeDisabled();
+ expect(current.value).toBe('[email protected]');
+ });
+
+ it('submits the new email and refreshes auth before closing', async () => {
+ const user = userEvent.setup();
+ const onSuccess = vi.fn();
+ render(<EmailChangeForm onSuccess={onSuccess} />);
+
+ await user.type(screen.getByPlaceholderText('Enter new email address'), '[email protected]');
+ await user.type(screen.getByPlaceholderText('Enter your current password to confirm'), 'Oldpass0!');
+ await user.click(screen.getByRole('button', { name: 'Update Email' }));
+
+ await waitFor(() => expect(onSuccess).toHaveBeenCalledOnce());
+ expect(put).toHaveBeenCalledWith('/user/email', { current_password: 'Oldpass0!', mail: '[email protected]' });
+ expect(refreshAuthInfo).toHaveBeenCalledOnce();
+ });
+
+ it('maps the email-already-exists code to friendly copy', async () => {
+ const user = userEvent.setup();
+ put.mockRejectedValueOnce(apiError('Users.ChangeEmailCurrentUser.EmailAlreadyExists', 'email already exists'));
+ render(<EmailChangeForm />);
+
+ await user.type(screen.getByPlaceholderText('Enter new email address'), '[email protected]');
+ await user.type(screen.getByPlaceholderText('Enter your current password to confirm'), 'Oldpass0!');
+ await user.click(screen.getByRole('button', { name: 'Update Email' }));
+
+ expect(await screen.findByText('Email address is already in use')).toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/features/authentication/email-change-form.tsx b/frontend/src/features/authentication/email-change-form.tsx
index 17dca164..d6dedcb6 100644
--- a/frontend/src/features/authentication/email-change-form.tsx
+++ b/frontend/src/features/authentication/email-change-form.tsx
@@ -1,5 +1,4 @@
import { zodResolver } from '@hookform/resolvers/zod';
-import { Eye, EyeOff } from 'lucide-react';
import { useState } from 'react';
import { useForm } from 'react-hook-form';
import { toast } from 'sonner';
@@ -9,7 +8,9 @@ import { Button } from '@/components/ui/button';
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
import { FormSubmitButton } from '@/components/ui/form-submit-button';
import { Input } from '@/components/ui/input';
-import { api, type ApiErrorResponse, type ApiHttpError } from '@/lib/axios';
+import { InputPassword } from '@/components/ui/input-password';
+import { Label } from '@/components/ui/label';
+import { api, getApiErrorCode, getApiErrorMessage } from '@/lib/axios';
import { useUser } from '@/providers/user-provider';
const emailChangeSchema = z.object({
@@ -21,6 +22,14 @@ const emailChangeSchema = z.object({
.max(50, { message: 'Email must not exceed 50 characters' }),
});
+const ERROR_BY_CODE: Record<string, string> = {
+ AuthRequired: 'Authentication required',
+ 'Users.ChangeEmailCurrentUser.EmailAlreadyExists': 'Email address is already in use',
+ 'Users.ChangeEmailCurrentUser.InvalidCurrentPassword': 'Current password is incorrect',
+ 'Users.ChangeEmailCurrentUser.InvalidEmail': 'New email does not meet requirements',
+ 'Users.NotFound': 'User not found',
+};
+
interface EmailChangeFormProps {
isModal?: boolean;
onCancel?: () => void;
@@ -31,7 +40,6 @@ type EmailChangeFormValues = z.infer<typeof emailChangeSchema>;
export function EmailChangeForm({ isModal = true, onCancel, onSuccess }: EmailChangeFormProps) {
const [error, setError] = useState<null | string>(null);
- const [showPassword, setShowPassword] = useState(false);
const { authInfo, refreshAuthInfo } = useUser();
const currentEmail = authInfo?.user?.mail || '';
@@ -53,49 +61,14 @@ export function EmailChangeForm({ isModal = true, onCancel, onSuccess }: EmailCh
});
form.reset();
- setShowPassword(false);
-
toast.success('Email successfully updated');
- // Refresh user info to update local state/display
await refreshAuthInfo();
- if (onSuccess) {
- onSuccess();
- }
+ onSuccess?.();
} catch (err: unknown) {
- const error = err as ApiHttpError;
- const responseData = error.response?.data as ApiErrorResponse | undefined;
-
- let errorMessage = 'Failed to update email';
-
- if (responseData?.msg) {
- errorMessage = responseData.msg;
- } else if (responseData?.code) {
- switch (responseData.code) {
- case 'AuthRequired':
- errorMessage = 'Authentication required';
- break;
- case 'Users.ChangeEmailCurrentUser.EmailAlreadyExists':
- errorMessage = 'Email address is already in use';
- break;
- case 'Users.ChangeEmailCurrentUser.InvalidCurrentPassword':
- errorMessage = 'Current password is incorrect';
- break;
- case 'Users.ChangeEmailCurrentUser.InvalidEmail':
- errorMessage = 'New email does not meet requirements';
- break;
- case 'Users.NotFound':
- errorMessage = 'User not found';
- break;
- default:
- errorMessage = responseData.msg || error.message || 'Failed to update email';
- }
- } else if (error.message) {
- errorMessage = error.message;
- }
-
- setError(errorMessage);
+ const code = getApiErrorCode(err);
+ setError((code && ERROR_BY_CODE[code]) ?? getApiErrorMessage(err, 'Failed to update email'));
}
};
@@ -105,12 +78,11 @@ export function EmailChangeForm({ isModal = true, onCancel, onSuccess }: EmailCh
className="flex flex-col gap-4"
onSubmit={form.handleSubmit(handleSubmit)}
>
- <div className="space-y-2">
- <label className="text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
- Current Email
- </label>
+ <div className="flex flex-col gap-2">
+ <Label htmlFor="current-email">Current Email</Label>
<Input
disabled
+ id="current-email"
value={currentEmail}
/>
</div>
@@ -140,27 +112,10 @@ export function EmailChangeForm({ isModal = true, onCancel, onSuccess }: EmailCh
<FormItem>
<FormLabel>Current Password</FormLabel>
<FormControl>
- <div className="relative">
- <Input
- {...field}
- placeholder="Enter your current password to confirm"
- type={showPassword ? 'text' : 'password'}
- />
- <Button
- className="absolute top-0 right-0 h-full px-3 py-2 hover:bg-transparent"
- onClick={() => setShowPassword(!showPassword)}
- size="sm"
- tabIndex={-1}
- type="button"
- variant="ghost"
- >
- {showPassword ? (
- <EyeOff className="text-muted-foreground size-4" />
- ) : (
- <Eye className="text-muted-foreground size-4" />
- )}
- </Button>
- </div>
+ <InputPassword
+ {...field}
+ placeholder="Enter your current password to confirm"
+ />
</FormControl>
<FormMessage />
</FormItem>
diff --git a/frontend/src/features/authentication/login-form.tsx b/frontend/src/features/authentication/login-form.tsx
index 16ae3bb7..04c976b9 100644
--- a/frontend/src/features/authentication/login-form.tsx
+++ b/frontend/src/features/authentication/login-form.tsx
@@ -12,6 +12,7 @@ import { Button } from '@/components/ui/button';
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
import { FormSubmitButton } from '@/components/ui/form-submit-button';
import { Input } from '@/components/ui/input';
+import { InputPassword } from '@/components/ui/input-password';
import { useUser } from '@/providers/user-provider';
import { PasswordChangeForm } from './password-change-form';
@@ -233,10 +234,9 @@ function LoginForm({ providers, returnUrl = '/flows/new' }: LoginFormProps) {
<FormItem>
<FormLabel>Password</FormLabel>
<FormControl>
- <Input
+ <InputPassword
{...field}
placeholder="Enter your password"
- type="password"
/>
</FormControl>
<FormMessage />
diff --git a/frontend/src/features/authentication/password-change-form.test.tsx b/frontend/src/features/authentication/password-change-form.test.tsx
new file mode 100644
index 00000000..ed83b3d7
--- /dev/null
+++ b/frontend/src/features/authentication/password-change-form.test.tsx
@@ -0,0 +1,70 @@
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+const { put } = vi.hoisted(() => ({ put: vi.fn() }));
+
+// Keep the pure helpers (`getApiErrorCode`, `getApiErrorMessage`) real — only the network call is stubbed.
+vi.mock('@/lib/axios', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('@/lib/axios')>();
+
+ return { ...actual, api: { ...actual.api, put } };
+});
+
+vi.mock('sonner', () => ({ toast: { error: vi.fn(), success: vi.fn() } }));
+
+import { PasswordChangeForm } from './password-change-form';
+
+const apiError = (code: string, msg: string) => ({ response: { data: { code, msg, status: 'error' } } });
+
+beforeEach(() => {
+ put.mockReset().mockResolvedValue({ status: 'success' });
+});
+
+describe('PasswordChangeForm', () => {
+ it('toggles password visibility via the InputPassword control', async () => {
+ const user = userEvent.setup();
+ render(<PasswordChangeForm />);
+
+ const current = screen.getByPlaceholderText('Enter your current password') as HTMLInputElement;
+ expect(current.type).toBe('password');
+
+ await user.click(screen.getAllByRole('button', { name: 'Show password' })[0]);
+
+ expect(current.type).toBe('text');
+ });
+
+ it('submits the snake_case payload — proves RHF ref/onChange survive the InputPassword hop', async () => {
+ const user = userEvent.setup();
+ const onSuccess = vi.fn();
+ render(<PasswordChangeForm onSuccess={onSuccess} />);
+
+ await user.type(screen.getByPlaceholderText('Enter your current password'), 'Oldpass0!');
+ await user.type(screen.getByPlaceholderText('Enter new password'), 'Abcdef1!gh');
+ await user.type(screen.getByPlaceholderText('Confirm new password'), 'Abcdef1!gh');
+ await user.click(screen.getByRole('button', { name: 'Update Password' }));
+
+ await waitFor(() => expect(onSuccess).toHaveBeenCalledOnce());
+ expect(put).toHaveBeenCalledWith('/user/password', {
+ confirm_password: 'Abcdef1!gh',
+ current_password: 'Oldpass0!',
+ password: 'Abcdef1!gh',
+ });
+ });
+
+ it('maps a backend error code to friendly copy instead of the raw msg', async () => {
+ const user = userEvent.setup();
+ put.mockRejectedValueOnce(
+ apiError('Users.ChangePasswordCurrentUser.InvalidCurrentPassword', 'invalid current password'),
+ );
+ render(<PasswordChangeForm />);
+
+ await user.type(screen.getByPlaceholderText('Enter your current password'), 'Oldpass0!');
+ await user.type(screen.getByPlaceholderText('Enter new password'), 'Abcdef1!gh');
+ await user.type(screen.getByPlaceholderText('Confirm new password'), 'Abcdef1!gh');
+ await user.click(screen.getByRole('button', { name: 'Update Password' }));
+
+ expect(await screen.findByText('Current password is incorrect')).toBeInTheDocument();
+ expect(screen.queryByText('invalid current password')).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/features/authentication/password-change-form.tsx b/frontend/src/features/authentication/password-change-form.tsx
index 30392a4f..3ab553ce 100644
--- a/frontend/src/features/authentication/password-change-form.tsx
+++ b/frontend/src/features/authentication/password-change-form.tsx
@@ -1,5 +1,4 @@
import { zodResolver } from '@hookform/resolvers/zod';
-import { Eye, EyeOff } from 'lucide-react';
import { useState } from 'react';
import { useForm } from 'react-hook-form';
import { toast } from 'sonner';
@@ -8,8 +7,8 @@ import * as z from 'zod';
import { Button } from '@/components/ui/button';
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
import { FormSubmitButton } from '@/components/ui/form-submit-button';
-import { Input } from '@/components/ui/input';
-import { api, type ApiErrorResponse, type ApiHttpError } from '@/lib/axios';
+import { InputPassword } from '@/components/ui/input-password';
+import { api, getApiErrorCode, getApiErrorMessage } from '@/lib/axios';
const passwordChangeSchema = z
.object({
@@ -48,6 +47,14 @@ const passwordChangeSchema = z
path: ['newPassword'],
});
+const ERROR_BY_CODE: Record<string, string> = {
+ AuthRequired: 'Authentication required',
+ 'Users.ChangePasswordCurrentUser.InvalidCurrentPassword': 'Current password is incorrect',
+ 'Users.ChangePasswordCurrentUser.InvalidNewPassword': 'New password does not meet requirements',
+ 'Users.ChangePasswordCurrentUser.InvalidPassword': 'Password validation failed',
+ 'Users.NotFound': 'User not found',
+};
+
interface PasswordChangeFormProps {
isModal?: boolean;
onCancel?: () => void;
@@ -66,9 +73,6 @@ export function PasswordChangeForm({
showSkip = false,
}: PasswordChangeFormProps) {
const [error, setError] = useState<null | string>(null);
- const [showCurrentPassword, setShowCurrentPassword] = useState(false);
- const [showNewPassword, setShowNewPassword] = useState(false);
- const [showConfirmPassword, setShowConfirmPassword] = useState(false);
const form = useForm<PasswordChangeFormValues>({
defaultValues: {
@@ -90,48 +94,12 @@ export function PasswordChangeForm({
});
form.reset();
- setShowCurrentPassword(false);
- setShowNewPassword(false);
- setShowConfirmPassword(false);
-
toast.success('Password successfully changed');
- if (onSuccess) {
- onSuccess();
- }
+ onSuccess?.();
} catch (err: unknown) {
- const error = err as ApiHttpError;
- const responseData = error.response?.data as ApiErrorResponse | undefined;
-
- let errorMessage = 'Failed to change password';
-
- if (responseData?.msg) {
- errorMessage = responseData.msg;
- } else if (responseData?.code) {
- switch (responseData.code) {
- case 'AuthRequired':
- errorMessage = 'Authentication required';
- break;
- case 'Users.ChangePasswordCurrentUser.InvalidCurrentPassword':
- errorMessage = 'Current password is incorrect';
- break;
- case 'Users.ChangePasswordCurrentUser.InvalidNewPassword':
- errorMessage = 'New password does not meet requirements';
- break;
- case 'Users.ChangePasswordCurrentUser.InvalidPassword':
- errorMessage = 'Password validation failed';
- break;
- case 'Users.NotFound':
- errorMessage = 'User not found';
- break;
- default:
- errorMessage = responseData.msg || error.message || 'Failed to change password';
- }
- } else if (error.message) {
- errorMessage = error.message;
- }
-
- setError(errorMessage);
+ const code = getApiErrorCode(err);
+ setError((code && ERROR_BY_CODE[code]) ?? getApiErrorMessage(err, 'Failed to change password'));
}
};
@@ -148,27 +116,10 @@ export function PasswordChangeForm({
<FormItem>
<FormLabel>Current Password</FormLabel>
<FormControl>
- <div className="relative">
- <Input
- {...field}
- placeholder="Enter your current password"
- type={showCurrentPassword ? 'text' : 'password'}
- />
- <Button
- className="absolute top-0 right-0 h-full px-3 py-2 hover:bg-transparent"
- onClick={() => setShowCurrentPassword(!showCurrentPassword)}
- size="sm"
- tabIndex={-1}
- type="button"
- variant="ghost"
- >
- {showCurrentPassword ? (
- <EyeOff className="text-muted-foreground size-4" />
- ) : (
- <Eye className="text-muted-foreground size-4" />
- )}
- </Button>
- </div>
+ <InputPassword
+ {...field}
+ placeholder="Enter your current password"
+ />
</FormControl>
<FormMessage />
</FormItem>
@@ -182,27 +133,10 @@ export function PasswordChangeForm({
<FormItem>
<FormLabel>New Password</FormLabel>
<FormControl>
- <div className="relative">
- <Input
- {...field}
- placeholder="Enter new password"
- type={showNewPassword ? 'text' : 'password'}
- />
- <Button
- className="absolute top-0 right-0 h-full px-3 py-2 hover:bg-transparent"
- onClick={() => setShowNewPassword(!showNewPassword)}
- size="sm"
- tabIndex={-1}
- type="button"
- variant="ghost"
- >
- {showNewPassword ? (
- <EyeOff className="text-muted-foreground size-4" />
- ) : (
- <Eye className="text-muted-foreground size-4" />
- )}
- </Button>
- </div>
+ <InputPassword
+ {...field}
+ placeholder="Enter new password"
+ />
</FormControl>
<FormDescription className="text-xs">
Must be 16+ characters, or 8+ with number, lowercase, uppercase, and special character
@@ -220,27 +154,10 @@ export function PasswordChangeForm({
<FormItem>
<FormLabel>Confirm New Password</FormLabel>
<FormControl>
- <div className="relative">
- <Input
- {...field}
- placeholder="Confirm new password"
- type={showConfirmPassword ? 'text' : 'password'}
- />
- <Button
- className="absolute top-0 right-0 h-full px-3 py-2 hover:bg-transparent"
- onClick={() => setShowConfirmPassword(!showConfirmPassword)}
- size="sm"
- tabIndex={-1}
- type="button"
- variant="ghost"
- >
- {showConfirmPassword ? (
- <EyeOff className="text-muted-foreground size-4" />
- ) : (
- <Eye className="text-muted-foreground size-4" />
- )}
- </Button>
- </div>
+ <InputPassword
+ {...field}
+ placeholder="Confirm new password"
+ />
</FormControl>
<FormMessage />
</FormItem>
diff --git a/frontend/src/features/authentication/profile-dialog.tsx b/frontend/src/features/authentication/profile-dialog.tsx
deleted file mode 100644
index 7507cf01..00000000
--- a/frontend/src/features/authentication/profile-dialog.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
-
-import { EmailChangeForm } from './email-change-form';
-import { PasswordChangeForm } from './password-change-form';
-
-interface ProfileDialogProps {
- onCancel: () => void;
- onSuccess: () => void;
-}
-
-export function ProfileDialog({ onCancel, onSuccess }: ProfileDialogProps) {
- return (
- <Tabs
- className="w-full"
- defaultValue="email"
- >
- <TabsList className="grid w-full grid-cols-2">
- <TabsTrigger value="email">Update Email</TabsTrigger>
- <TabsTrigger value="password">Change Password</TabsTrigger>
- </TabsList>
- <TabsContent value="email">
- <div className="pt-2">
- <EmailChangeForm
- onCancel={onCancel}
- onSuccess={onSuccess}
- />
- </div>
- </TabsContent>
- <TabsContent value="password">
- <div className="pt-2">
- <PasswordChangeForm
- onCancel={onCancel}
- onSuccess={onSuccess}
- />
- </div>
- </TabsContent>
- </Tabs>
- );
-}
diff --git a/frontend/src/lib/axios.ts b/frontend/src/lib/axios.ts
index 24d3af96..96d81ead 100644
--- a/frontend/src/lib/axios.ts
+++ b/frontend/src/lib/axios.ts
@@ -245,5 +245,15 @@ export const getApiErrorStatusCode = (error: unknown): number | undefined => {
return httpError.statusCode ?? httpError.response?.status;
};
+export const getApiErrorCode = (error: unknown): string | undefined => {
+ if (!error || typeof error !== 'object') {
+ return undefined;
+ }
+
+ const responseData = (error as ApiHttpError).response?.data;
+
+ return responseData && typeof responseData === 'object' ? (responseData as ApiErrorResponse).code : undefined;
+};
+
export default axios;
export { axios };
diff --git a/frontend/src/lib/route-titles/index.ts b/frontend/src/lib/route-titles/index.ts
index 0e430826..1f48423c 100644
--- a/frontend/src/lib/route-titles/index.ts
+++ b/frontend/src/lib/route-titles/index.ts
@@ -34,6 +34,7 @@ export type TitleResolver = ((params: RouteParams) => string) | ComponentType<{
* from this registry onto the matching <Route>.
*/
export const routeTitles = {
+ account: { title: 'Account' },
apiTokens: { title: 'API Tokens' },
dashboard: { title: 'Dashboard' },
flow: {
diff --git a/frontend/src/pages/settings/settings-account.tsx b/frontend/src/pages/settings/settings-account.tsx
new file mode 100644
index 00000000..6b82e910
--- /dev/null
+++ b/frontend/src/pages/settings/settings-account.tsx
@@ -0,0 +1,118 @@
+import { format } from 'date-fns';
+import { enUS } from 'date-fns/locale';
+import { Lock, Mail } from 'lucide-react';
+import { useState } from 'react';
+import { Navigate } from 'react-router-dom';
+
+import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
+import { EmailChangeForm } from '@/features/authentication/email-change-form';
+import { PasswordChangeForm } from '@/features/authentication/password-change-form';
+import { useUser } from '@/providers/user-provider';
+
+type EditingSection = 'email' | 'password' | null;
+
+function SettingsAccount() {
+ const { authInfo } = useUser();
+ const user = authInfo?.user;
+ const [editing, setEditing] = useState<EditingSection>(null);
+
+ if (user?.type !== 'local') {
+ return (
+ <Navigate
+ replace
+ to="/settings/providers"
+ />
+ );
+ }
+
+ const stopEditing = () => setEditing(null);
+
+ const displayName = user.name?.trim() || user.mail;
+ const initial = (displayName || '?').charAt(0).toUpperCase();
+ const createdAt = user.created_at ? new Date(user.created_at) : null;
+ const memberSince =
+ createdAt && !Number.isNaN(createdAt.getTime()) ? format(createdAt, 'MMMM yyyy', { locale: enUS }) : null;
+
+ return (
+ <div className="mx-auto flex max-w-2xl flex-col gap-4">
+ <Card>
+ <CardHeader className="flex-row items-center gap-4">
+ <div className="bg-muted text-foreground flex size-12 shrink-0 items-center justify-center rounded-lg text-lg font-semibold">
+ {initial}
+ </div>
+ <div className="flex flex-1 flex-col gap-0.5">
+ <CardTitle className="truncate">{displayName}</CardTitle>
+ {memberSince && <CardDescription>Member since {memberSince}</CardDescription>}
+ </div>
+ <Badge variant="secondary">Local account</Badge>
+ </CardHeader>
+ </Card>
+
+ <Card>
+ <CardHeader className="flex-row items-start justify-between gap-4">
+ <div className="grid gap-1.5">
+ <CardTitle>Email address</CardTitle>
+ <CardDescription>The email you use to sign in.</CardDescription>
+ </div>
+ {editing !== 'email' && (
+ <Button
+ onClick={() => setEditing('email')}
+ size="sm"
+ variant="outline"
+ >
+ Change
+ </Button>
+ )}
+ </CardHeader>
+ <CardContent>
+ {editing === 'email' ? (
+ <EmailChangeForm
+ onCancel={stopEditing}
+ onSuccess={stopEditing}
+ />
+ ) : (
+ <div className="text-muted-foreground flex items-center gap-2 text-sm">
+ <Mail className="size-4 shrink-0" />
+ <span className="truncate">{user.mail}</span>
+ </div>
+ )}
+ </CardContent>
+ </Card>
+
+ <Card>
+ <CardHeader className="flex-row items-start justify-between gap-4">
+ <div className="grid gap-1.5">
+ <CardTitle>Password</CardTitle>
+ <CardDescription>Change your account password.</CardDescription>
+ </div>
+ {editing !== 'password' && (
+ <Button
+ onClick={() => setEditing('password')}
+ size="sm"
+ variant="outline"
+ >
+ Change
+ </Button>
+ )}
+ </CardHeader>
+ <CardContent>
+ {editing === 'password' ? (
+ <PasswordChangeForm
+ onCancel={stopEditing}
+ onSuccess={stopEditing}
+ />
+ ) : (
+ <div className="text-muted-foreground flex items-center gap-2 text-sm">
+ <Lock className="size-4 shrink-0" />
+ <span>••••••••••••</span>
+ </div>
+ )}
+ </CardContent>
+ </Card>
+ </div>
+ );
+}
+
+export default SettingsAccount;