Files
pp-tcms/frontend/types/user.ts
LittleYellow 1c977f9266 feat: add LDAP authentication settings and toggle
Add an admin-only LDAP configuration UI with an enable toggle and full
sign-in integration.

Backend:
- ldapSettings model + migration (single-row config)
- GET/PUT/test routes under /ldap (admin-gated; bind password masked)
- shared ldapClient with RFC 4515 filter escaping and empty-password guard
- signin tries local auth first, then LDAP when enabled (find-or-create
  local user) so the bootstrap admin is never locked out

Frontend:
- LDAP settings page (Switch + form + test connection) under /admin/ldap
- AdminNav tabs between user management and LDAP
- ldapControl util, types, and Ldap i18n namespace for all 6 locales

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 07:20:08 +08:00

110 lines
2.3 KiB
TypeScript

import { LocaleCodeType } from './locale';
import { ToastMessages } from './toast';
export type UserType = {
id: number | null;
email: string;
password: string;
username: string;
role: number;
avatarPath: string | null;
locale: LocaleCodeType | null;
};
export type TokenProps = {
toastMessages?: ToastMessages;
locale?: LocaleCodeType;
children?: React.ReactNode;
};
export type TokenType = {
access_token: string;
expires_at: number;
user: UserType | null;
};
export type TokenContextType = {
token: {
access_token: string;
expires_at: number;
user: UserType | null;
};
isSignedIn: () => boolean;
isAdmin: () => boolean;
isProjectOwner: (projectId: number) => boolean;
isProjectManager: (projectId: number) => boolean;
isProjectDeveloper: (projectId: number) => boolean;
isProjectReporter: (projectId: number) => boolean;
refreshProjectRoles: () => void;
setToken: (token: TokenType) => void;
storeTokenToLocalStorage: (token: TokenType) => void;
removeTokenFromLocalStorage: () => void;
};
export type ProjectRoleType = {
projectId: number;
isOwner: boolean;
isMember: boolean;
role: number;
};
export type AuthMessages = {
title: string;
linkTitle: string;
submitTitle: string;
signInAsGuest: string;
email: string;
username: string;
password: string;
confirmPassword: string;
invalidEmail: string;
invalidPassword: string;
usernameEmpty: string;
passwordDoesNotMatch: string;
EmailAlreadyExist: string;
emailNotExist: string;
signupError: string;
signinError: string;
demoPageWarning: string;
};
export type AdminMessages = {
userManagement: string;
ldap: string;
avatar: string;
id: string;
email: string;
username: string;
role: string;
noUsersFound: string;
administrator: string;
user: string;
quitAdmin: string;
quit: string;
quitConfirm: string;
close: string;
roleChanged: string;
lostAdminAuth: string;
atLeast: string;
resetPassword: string;
reset: string;
invalidPassword: string;
passwordNotMatch: string;
};
export type AccountDropDownMessages = {
account: string;
profileSettings: string;
signUp: string;
signIn: string;
signOut: string;
};
export type MemberType = {
id: number | null;
userId: number;
projectId: number;
role: number;
User: UserType;
};