feat: add more security settings

This commit is contained in:
Steven
2024-08-29 20:13:10 +08:00
parent 6c54732cd1
commit 0ac2554545
15 changed files with 312 additions and 247 deletions

View File

@ -26,6 +26,22 @@ const WorkspaceSecuritySection = () => {
);
};
const toggleDisallowPasswordAuth = async (on: boolean) => {
if (on) {
const confirmed = window.confirm("Are you sure to disallow password auth? This will prevent users from signing in with password.");
if (!confirmed) {
return;
}
}
await updateWorkspaceSetting(
WorkspaceSetting.fromPartial({
disallowPasswordAuth: on,
}),
["disallow_password_auth"],
);
};
const updateWorkspaceSetting = async (workspaceSetting: WorkspaceSetting, updateMask: string[]) => {
if (updateMask.length === 0) {
toast.error("No changes made");
@ -58,6 +74,15 @@ const WorkspaceSecuritySection = () => {
endDecorator={<span>{t("settings.workspace.disallow-user-registration.self")}</span>}
/>
</div>
<div>
<Switch
className="dark:text-gray-500"
size="lg"
checked={workspaceStore.setting.disallowPasswordAuth}
onChange={(event) => toggleDisallowPasswordAuth(event.target.checked)}
endDecorator={<span>{"Disallow password auth"}</span>}
/>
</div>
</div>
</div>
);