feat: Implement AI Chat Agent, Email Notifications, and UI enhancements
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
+10
-4
@@ -15,7 +15,7 @@ export async function hashPassword(password: string) {
|
||||
return `${buf.toString("hex")}.${salt}`;
|
||||
}
|
||||
|
||||
async function comparePassword(supplied: string, stored: string) {
|
||||
export async function comparePassword(supplied: string, stored: string) {
|
||||
const [hashed, salt] = stored.split(".");
|
||||
const hashedBuf = Buffer.from(hashed, "hex");
|
||||
const suppliedBuf = (await scryptAsync(supplied, salt, 64)) as Buffer;
|
||||
@@ -28,11 +28,14 @@ export function setupAuth(app: Express) {
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
store: storage.sessionStore,
|
||||
cookie: {
|
||||
secure: process.env.NODE_ENV === "production" && process.env.SECURE_COOKIES === "true",
|
||||
sameSite: "lax",
|
||||
// maxAge not set by default (session cookie)
|
||||
},
|
||||
};
|
||||
|
||||
if (app.get("env") === "production") {
|
||||
app.set("trust proxy", 1);
|
||||
}
|
||||
|
||||
|
||||
app.use(session(sessionSettings));
|
||||
app.use(passport.initialize());
|
||||
@@ -128,6 +131,9 @@ export function setupAuth(app: Express) {
|
||||
});
|
||||
|
||||
app.post("/api/login", passport.authenticate("local"), (req, res) => {
|
||||
if (req.body.rememberMe) {
|
||||
req.session.cookie.maxAge = 30 * 24 * 60 * 60 * 1000; // 30 days
|
||||
}
|
||||
res.status(200).json(req.user);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user