Skip to content

Add Account Settings page #8672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 60 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
8f2428c
Update navbar links and add account settings route
hotzenklotz Jun 4, 2025
58c2d49
Refactor account settings view and add profile management
hotzenklotz Jun 4, 2025
9367076
WIP account setting sub page styling
hotzenklotz Jun 4, 2025
33b0b1a
formatting
hotzenklotz Jun 5, 2025
4a4c460
fix typeing
hotzenklotz Jun 5, 2025
8e18e2a
added breadcrumbs
hotzenklotz Jun 5, 2025
77e602a
added redirects to old routes
hotzenklotz Jun 5, 2025
09d50ea
apply feedback
hotzenklotz Jun 5, 2025
14e624b
fix typo
hotzenklotz Jun 5, 2025
cb70499
move account related views into separate directory
hotzenklotz Jun 6, 2025
dd6c8e6
style background
hotzenklotz Jun 6, 2025
4cd2ecd
refactor orga settings in new style
hotzenklotz Jun 6, 2025
6a4b559
Merge branch 'master' of github.com:scalableminds/webknossos into acc…
hotzenklotz Jun 16, 2025
d022413
Merge branch 'account-settings-page' into orga-settings-page
hotzenklotz Jun 16, 2025
82fd616
Refactor account settings components and update organization navigation
hotzenklotz Jun 16, 2025
aa95b90
Enhance organization management UI and functionality
hotzenklotz Jun 16, 2025
a2002cb
formatting
hotzenklotz Jun 16, 2025
b7543ea
Enhance organization-related components and UI
hotzenklotz Jun 16, 2025
749861a
fix setting cards buttons
hotzenklotz Jun 16, 2025
44e0966
changelog
hotzenklotz Jun 16, 2025
76616d0
Merge branch 'master' of github.com:scalableminds/webknossos into acc…
hotzenklotz Jun 17, 2025
8716091
Merge branch 'account-settings-page' into orga-settings-page
hotzenklotz Jun 17, 2025
55bf833
Update frontend/javascripts/admin/organization/pricing_plan_utils.ts
hotzenklotz Jun 18, 2025
513011b
applied PR feedback
hotzenklotz Jun 18, 2025
01ae877
Merge branch 'orga-settings-page' of github.com:scalableminds/webknos…
hotzenklotz Jun 18, 2025
67e8819
Show owner email in notifications
hotzenklotz Jun 18, 2025
121c91a
fix pricing plan label
hotzenklotz Jun 18, 2025
9ee0b24
Merge branch 'master' of github.com:scalableminds/webknossos into acc…
hotzenklotz Jun 23, 2025
203ae75
Merge branch 'account-settings-page' into orga-settings-page
hotzenklotz Jun 23, 2025
df8e81d
do not show upgrade options for custom plans yet
hotzenklotz Jun 23, 2025
b094806
update the account settings page with card style
hotzenklotz Jun 23, 2025
a91f88b
Update frontend/javascripts/router.tsx
hotzenklotz Jun 24, 2025
38c426e
Update frontend/javascripts/admin/account/account_password_view.tsx
hotzenklotz Jun 24, 2025
511c4fb
Merge branch 'master' into account-settings-page
hotzenklotz Jun 24, 2025
d0cd5b3
more stuff
hotzenklotz Jun 24, 2025
66086aa
fix null / infinity on update
hotzenklotz Jun 24, 2025
1903218
appled PR feedback
hotzenklotz Jun 24, 2025
d61a522
apply PR feedback
hotzenklotz Jun 24, 2025
f2ee79d
fix linitng
hotzenklotz Jun 24, 2025
2ed707a
Merge branch 'account-settings-page' into orga-settings-page
hotzenklotz Jun 24, 2025
1f74811
Merge branch 'orga-settings-page' into account-settings-page-cards
hotzenklotz Jun 24, 2025
125ed0f
formatting
hotzenklotz Jun 24, 2025
e489f9d
Rework organization page (#8679)
hotzenklotz Jun 25, 2025
c8e6a4e
Merge branch 'account-settings-page-cards' into account-settings-page
hotzenklotz Jun 25, 2025
a84f9fc
Merge branch 'master' of github.com:scalableminds/webknossos into acc…
hotzenklotz Jun 25, 2025
0418bbf
refinement
hotzenklotz Jun 25, 2025
c12b0a3
changelog
hotzenklotz Jun 25, 2025
b3ef603
Merge branch 'master' of github.com:scalableminds/webknossos into acc…
hotzenklotz Jun 25, 2025
58af2a4
apply coderabbit feedback
hotzenklotz Jun 25, 2025
52728d5
redirect after orga removal
hotzenklotz Jun 25, 2025
235be66
apply feedback
hotzenklotz Jun 25, 2025
f734e92
Update unreleased_changes/8672.md
hotzenklotz Jun 25, 2025
0260a0e
Merge branch 'master' of github.com:scalableminds/webknossos into acc…
hotzenklotz Jun 25, 2025
8b8fb57
apply PR feedback
hotzenklotz Jun 25, 2025
0bb572d
Update unreleased_changes/8679.md
hotzenklotz Jun 25, 2025
6762eee
Merge branch 'master' of github.com:scalableminds/webknossos into acc…
hotzenklotz Jun 26, 2025
e6a69d5
Merge branch 'account-settings-page' of github.com:scalableminds/webk…
hotzenklotz Jun 26, 2025
6e8e483
add theme switching to command palette
philippotto Jun 27, 2025
c3be491
add toast.error
philippotto Jun 27, 2025
7d98ca1
sort imports
philippotto Jun 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@
},
"overrides": [
{
"include": [
"**/package.json"
],
"include": ["**/package.json"],
"formatter": {
"lineWidth": 1
}
}
]
}
}
94 changes: 94 additions & 0 deletions frontend/javascripts/admin/account/account_auth_token_view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { InfoCircleOutlined, SwapOutlined } from "@ant-design/icons";
import { getAuthToken, revokeAuthToken } from "admin/rest_api";
import { Button, Descriptions, Popover, Spin, Typography } from "antd";
import { useWkSelector } from "libs/react_hooks";
import { useEffect, useState } from "react";
import { AccountSettingsTitle } from "./account_profile_view";

const { Text } = Typography;

function AccountAuthTokenView() {
const activeUser = useWkSelector((state) => state.activeUser);
const [isLoading, setIsLoading] = useState<boolean>(true);
const [currentToken, setCurrentToken] = useState<string>("");

useEffect(() => {
fetchData();
}, []);

async function fetchData(): Promise<void> {
const token = await getAuthToken();
setCurrentToken(token);
setIsLoading(false);
}

const handleRevokeToken = async (): Promise<void> => {
try {
setIsLoading(true);
await revokeAuthToken();
const token = await getAuthToken();
setCurrentToken(token);
} finally {
setIsLoading(false);
}
};

const APIitems = [
{
label: "Auth Token",
children: (
<Text code copyable>
{currentToken}
</Text>
),
},
{
label: (
<>
<span className="icon-margin-right">Token Revocation</span>
<Popover
content="Revoke your token if it has been compromised or if you suspect someone else has gained
access to it. This will invalidate all active sessions."
>
<InfoCircleOutlined />
</Popover>
</>
),
children: (
<Button icon={<SwapOutlined />} onClick={handleRevokeToken}>
Revoke and Generate New Token
</Button>
),
},
...(activeUser
? [
{
label: "Organization ID",
children: (
<Text code copyable>
{activeUser.organization}
</Text>
),
},
]
: []),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add null safety check for activeUser.organization.

While activeUser is checked at the component level, accessing activeUser.organization should still be safely handled.

     ...(activeUser
       ? [
           {
             label: "Organization ID",
             children: (
               <Text code copyable>
-                {activeUser.organization}
+                {activeUser.organization || "N/A"}
               </Text>
             ),
           },
         ]
       : []),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
...(activeUser
? [
{
label: "Organization ID",
children: (
<Text code copyable>
{activeUser.organization}
</Text>
),
},
]
: []),
...(activeUser
? [
{
label: "Organization ID",
children: (
<Text code copyable>
{activeUser.organization || "N/A"}
</Text>
),
},
]
: []),
🤖 Prompt for AI Agents
In frontend/javascripts/admin/account/account_auth_token_view.tsx around lines
63 to 74, the code accesses activeUser.organization without null safety, which
can cause errors if organization is undefined or null. Add a null safety check
when accessing activeUser.organization, such as using optional chaining or a
conditional to ensure the code handles cases where organization might be
missing.

{
label: "API Documentation",
children: <a href="https://docs.webknossos.org/webknossos-py/index.html">Read the docs</a>,
},
];

return (
<div>
<AccountSettingsTitle
title="API Authorization"
description="Access the WEBKNOSSO Python API with your API token"
/>
<Spin size="large" spinning={isLoading}>
<Descriptions column={2} layout="vertical" colon={false} items={APIitems} />
</Spin>
</div>
);
}

export default AccountAuthTokenView;
208 changes: 208 additions & 0 deletions frontend/javascripts/admin/account/account_password_view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
import { LockOutlined } from "@ant-design/icons";
import { Alert, Button, Descriptions, Form, Input, List, Space } from "antd";
import Request from "libs/request";
import Toast from "libs/toast";
import messages from "messages";
import { useState } from "react";
import { type RouteComponentProps, withRouter } from "react-router-dom";
import { logoutUserAction } from "viewer/model/actions/user_actions";
import Store from "viewer/store";
import { AccountSettingsTitle } from "./account_profile_view";
const FormItem = Form.Item;
const { Password } = Input;

type Props = {
history: RouteComponentProps["history"];
};

const MIN_PASSWORD_LENGTH = 8;

function AccountPasswordView({ history }: Props) {
const [form] = Form.useForm();
const [isResetPasswordVisible, setResetPasswordVisible] = useState(false);

function onFinish(formValues: Record<string, any>) {
Request.sendJSONReceiveJSON("/api/auth/changePassword", {
data: formValues,
}).then(async () => {
Toast.success(messages["auth.reset_pw_confirmation"]);
await Request.receiveJSON("/api/auth/logout");
history.push("/auth/login");
Store.dispatch(logoutUserAction());
});
}

function checkPasswordsAreMatching(value: string, otherPasswordFieldKey: string[]) {
const otherFieldValue = form.getFieldValue(otherPasswordFieldKey);

if (value && otherFieldValue) {
if (value !== otherFieldValue) {
return Promise.reject(new Error(messages["auth.registration_password_mismatch"]));
} else if (form.getFieldError(otherPasswordFieldKey).length > 0) {
// If the other password field still has errors, revalidate it.
form.validateFields([otherPasswordFieldKey]);
}
}

return Promise.resolve();
}

function getPasswordComponent() {
return isResetPasswordVisible ? (
<Form onFinish={onFinish} form={form}>
<FormItem
name="oldPassword"
rules={[
{
required: true,
message: messages["auth.reset_old_password"],
},
]}
>
<Password
prefix={
<LockOutlined
style={{
fontSize: 13,
}}
/>
}
placeholder="Old Password"
/>
</FormItem>
<FormItem
hasFeedback
name={["password", "password1"]}
rules={[
{
required: true,
message: messages["auth.reset_new_password"],
},
{
min: MIN_PASSWORD_LENGTH,
message: messages["auth.registration_password_length"],
},
{
validator: (_, value: string) =>
checkPasswordsAreMatching(value, ["password", "password2"]),
},
]}
>
<Password
prefix={
<LockOutlined
style={{
fontSize: 13,
}}
/>
}
placeholder="New Password"
/>
</FormItem>
<FormItem
hasFeedback
name={["password", "password2"]}
rules={[
{
required: true,
message: messages["auth.reset_new_password2"],
},
{
min: MIN_PASSWORD_LENGTH,
message: messages["auth.registration_password_length"],
},
{
validator: (_, value: string) =>
checkPasswordsAreMatching(value, ["password", "password1"]),
},
]}
>
<Password
prefix={
<LockOutlined
style={{
fontSize: 13,
}}
/>
}
placeholder="Confirm New Password"
/>
</FormItem>
<Alert
type="info"
message={messages["auth.reset_logout"]}
showIcon
style={{
marginBottom: 24,
}}
/>
<FormItem>
<Space>
<Button onClick={() => setResetPasswordVisible(false)}>Cancel</Button>
<Button type="primary" htmlType="submit">
Update Password
</Button>
</Space>
</FormItem>
</Form>
) : (
<>
<Space.Compact>
<Input.Password visibilityToggle={false} disabled value="******************" />
<Button type="primary" onClick={handleResetPassword}>
Reset Password
</Button>
</Space.Compact>
</>
);
}

function handleResetPassword() {
setResetPasswordVisible(true);
}

const passwordItems = [
{
label: "Password",
children: getPasswordComponent(),
},
];

const passKeyList = [
{
name: "passkey1",
details: "2024-05-01",
},
{
name: "passkey2",
details: "2025-05-01",
},
];

return (
<div>
<AccountSettingsTitle title="Password" description="Manage and update your password" />
<Descriptions
column={2}
layout="vertical"
colon={false}
items={passwordItems}
style={{ marginBottom: "3rem" }}
/>

<AccountSettingsTitle title="Passkeys" description="Login passwordless with Passkeys" />
<List
className="demo-loadmore-list"
itemLayout="horizontal"
dataSource={passKeyList}
renderItem={(item) => (
<List.Item actions={[<a key="list-delete">Delete</a>]}>
<List.Item.Meta title={item.name} description={item.details} />
</List.Item>
)}
/>
</div>
);
}

export default withRouter<RouteComponentProps, any>(AccountPasswordView);
Loading
Loading