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 all 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
2 changes: 1 addition & 1 deletion app/controllers/OrganizationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class OrganizationController @Inject()(
_ <- Fox.fromBool(request.identity.isAdminOf(organization._id)) ?~> "notAllowed" ~> FORBIDDEN
_ <- organizationDAO.updateFields(organization._id, name, newUserMailingList)
updated <- organizationDAO.findOne(organization._id)
organizationJson <- organizationService.publicWrites(updated)
organizationJson <- organizationService.publicWrites(updated, Some(request.identity))
} yield Ok(organizationJson)
}
}
Expand Down
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
}
}
]
}
}
108 changes: 108 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,108 @@
import { ExportOutlined, SwapOutlined } from "@ant-design/icons";
import { getAuthToken, revokeAuthToken } from "admin/rest_api";
import { Button, Col, Row, Spin, Typography } from "antd";
import { useWkSelector } from "libs/react_hooks";
import Toast from "libs/toast";
import { useEffect, useState } from "react";
import { SettingsCard } from "./helpers/settings_card";
import { SettingsTitle } from "./helpers/settings_title";

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> {
try {
const token = await getAuthToken();
setCurrentToken(token);
} catch (error) {
Toast.error("Failed to fetch auth token. Please refresh the page to try again.");
console.error("Failed to fetch auth token:", error);
} finally {
setIsLoading(false);
}
}

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

const APIitems = [
{
title: "Auth Token",
value: (
<Text code copyable>
{currentToken}
</Text>
),
},
{
title: "Token Revocation",
explanation:
"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.",
value: (
<Button icon={<SwapOutlined />} type="primary" ghost onClick={handleRevokeToken}>
Revoke and Generate New Token
</Button>
),
},
...(activeUser
? [
{
title: "Organization ID",
value: (
<Text code copyable>
{activeUser.organization}
</Text>
),
},
]
: []),
{
title: "API Documentation",
value: (
<a href="https://docs.webknossos.org/webknossos-py/index.html">
Read the docs <ExportOutlined />
</a>
),
},
];

return (
<div>
<SettingsTitle
title="API Authorization"
description="Access the WEBKNOSSO Python API with your API token"
/>
<Spin size="large" spinning={isLoading}>
<Row gutter={[24, 24]} style={{ marginBottom: 24 }}>
{APIitems.map((item) => (
<Col span={12} key={item.title}>
<SettingsCard
title={item.title}
description={item.value}
explanation={item.explanation}
/>
</Col>
))}
</Row>
</Spin>
</div>
);
}

export default AccountAuthTokenView;
200 changes: 200 additions & 0 deletions frontend/javascripts/admin/account/account_password_view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import { EditOutlined, LockOutlined } from "@ant-design/icons";
import { changePassword, logoutUser } from "admin/rest_api";
import { Alert, Button, Col, Form, Input, Row, Space } from "antd";
import Toast from "libs/toast";
import messages from "messages";
import { useState } from "react";
import { useHistory } from "react-router-dom";
import { logoutUserAction } from "viewer/model/actions/user_actions";
import Store from "viewer/store";
import { SettingsCard } from "./helpers/settings_card";
import { SettingsTitle } from "./helpers/settings_title";
const FormItem = Form.Item;
const { Password } = Input;

const MIN_PASSWORD_LENGTH = 8;

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

function onFinish(formValues: Record<string, any>) {
changePassword(formValues)
.then(async () => {
Toast.success(messages["auth.reset_pw_confirmation"]);
await logoutUser();
Store.dispatch(logoutUserAction());
history.push("/auth/login");
})
.catch((error) => {
console.error("Password change failed:", error);
Toast.error("Failed to change password. Please try again.");
});
}

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>
) : (
"***********"
);
}

function handleResetPassword() {
setResetPasswordVisible(true);
}

const passKeyList = [
{
title: "Coming soon",
value: "Passwordless login with passkeys is coming soon",
// action: <Button type="default" shape="circle" icon={<DeleteOutlined />} size="small" />,
action: undefined,
},
];

return (
<div>
<SettingsTitle title="Password" description="Manage and update your password" />
<Row gutter={[24, 24]} style={{ marginBottom: 24 }}>
<Col span={12}>
<SettingsCard
title="Password"
description={getPasswordComponent()}
action={
<Button
type="default"
shape="circle"
icon={<EditOutlined />}
size="small"
onClick={handleResetPassword}
/>
}
/>
</Col>
</Row>

<SettingsTitle title="Passkeys" description="Login passwordless with Passkeys" />
<Row gutter={[24, 24]} style={{ marginBottom: 24 }}>
{passKeyList.map((item) => (
<Col span={12} key={item.title}>
<SettingsCard title={item.title} description={item.value} action={item.action} />
</Col>
))}
</Row>
</div>
);
}

export default AccountPasswordView;
Loading