ecc340e7b1
Dark mode: CSS custom properties + .dark class toggled via Redux/localStorage, with a theme toggle in the Header and Settings page. Foundation didn't exist yet despite prior assumption, so it was built from scratch. SQLite: new DB_ENGINE=mongo|sqlite env var selects the metadata backend at runtime (Mongo stays default, no behavior change unless opted in). File/thumbnail bytes continue to use the existing fs/S3 storage path. Implemented via a shared DB interface (dbTypes.ts) with parallel mongoDB/ and sqliteDB/ implementations, selected through dbFactory.ts, with JWT/encryption logic extracted into userCrypto.ts so both engines share it.
42 lines
976 B
TypeScript
42 lines
976 B
TypeScript
import { Response } from "express";
|
|
import NotFoundError from "./NotFoundError";
|
|
import { createLoginCookie } from "../cookies/create-cookies";
|
|
import { getUserDB } from "../db/dbFactory";
|
|
|
|
const userDB = getUserDB();
|
|
|
|
type userAccessType = {
|
|
_id: any;
|
|
emailVerified: boolean;
|
|
email: string;
|
|
botChecked: boolean;
|
|
};
|
|
|
|
const userUpdateCheck = async (
|
|
res: Response,
|
|
id: string,
|
|
uuid: string | undefined
|
|
) => {
|
|
const updatedUser = await userDB.getUserInfo(id);
|
|
|
|
if (!updatedUser) throw new NotFoundError("Cannot find updated user auth");
|
|
|
|
if (updatedUser.emailVerified) {
|
|
const { accessToken, refreshToken } = await updatedUser.generateAuthToken(
|
|
uuid
|
|
);
|
|
createLoginCookie(res, accessToken, refreshToken);
|
|
}
|
|
|
|
let strippedUser: userAccessType = {
|
|
_id: updatedUser._id,
|
|
emailVerified: updatedUser.emailVerified!,
|
|
email: updatedUser.email,
|
|
botChecked: false,
|
|
};
|
|
|
|
return strippedUser;
|
|
};
|
|
|
|
export default userUpdateCheck;
|