mirror of
https://github.com/docmost/docmost.git
synced 2025-11-20 16:11:09 +10:00
feat(EE): LDAP integration (#1515)
* LDAP - WIP * WIP * add hasGeneratedPassword * fix jotai atom * - don't require password confirmation for MFA is user has auto generated password (LDAP) - cleanups * fix * reorder * update migration * update default * fix type error
This commit is contained in:
@ -1,16 +1,41 @@
|
||||
import { atom } from "jotai";
|
||||
import { atomWithStorage } from "jotai/utils";
|
||||
|
||||
import { ICurrentUser } from "@/features/user/types/user.types";
|
||||
import { focusAtom } from "jotai-optics";
|
||||
import { ICurrentUser, IUser } from "@/features/user/types/user.types";
|
||||
import { IWorkspace } from "@/features/workspace/types/workspace.types";
|
||||
|
||||
export const currentUserAtom = atomWithStorage<ICurrentUser | null>(
|
||||
"currentUser",
|
||||
null,
|
||||
);
|
||||
|
||||
export const userAtom = focusAtom(currentUserAtom, (optic) =>
|
||||
optic.prop("user"),
|
||||
export const userAtom = atom(
|
||||
(get) => {
|
||||
const currentUser = get(currentUserAtom);
|
||||
return currentUser?.user ?? null;
|
||||
},
|
||||
(get, set, newUser: IUser) => {
|
||||
const currentUser = get(currentUserAtom);
|
||||
if (currentUser) {
|
||||
set(currentUserAtom, {
|
||||
...currentUser,
|
||||
user: newUser,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
export const workspaceAtom = focusAtom(currentUserAtom, (optic) =>
|
||||
optic.prop("workspace"),
|
||||
|
||||
export const workspaceAtom = atom(
|
||||
(get) => {
|
||||
const currentUser = get(currentUserAtom);
|
||||
return currentUser?.workspace ?? null;
|
||||
},
|
||||
(get, set, newWorkspace: IWorkspace) => {
|
||||
const currentUser = get(currentUserAtom);
|
||||
if (currentUser) {
|
||||
set(currentUserAtom, {
|
||||
...currentUser,
|
||||
workspace: newWorkspace,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@ -25,7 +25,7 @@ function LanguageSwitcher() {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [user, setUser] = useAtom(userAtom);
|
||||
const [language, setLanguage] = useState(
|
||||
user?.locale === "en" ? "en-US" : user.locale,
|
||||
user?.locale === "en" ? "en-US" : user?.locale,
|
||||
);
|
||||
|
||||
const handleChange = async (value: string) => {
|
||||
|
||||
@ -20,6 +20,7 @@ export interface IUser {
|
||||
deletedAt: Date;
|
||||
fullPageWidth: boolean; // used for update
|
||||
pageEditMode: string; // used for update
|
||||
hasGeneratedPassword?: boolean;
|
||||
}
|
||||
|
||||
export interface ICurrentUser {
|
||||
|
||||
@ -5,7 +5,8 @@ import { useState } from "react";
|
||||
import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts";
|
||||
import { IWorkspace } from "@/features/workspace/types/workspace.types.ts";
|
||||
import { TextInput, Button } from "@mantine/core";
|
||||
import { useForm, zodResolver } from "@mantine/form";
|
||||
import { useForm } from "@mantine/form";
|
||||
import { zodResolver } from "mantine-form-zod-resolver";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
Reference in New Issue
Block a user