mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
feat: Configurable Verification Email Expiry Time
This commit is contained in:
parent
114deecc4e
commit
a36902866a
3 changed files with 11 additions and 3 deletions
|
|
@ -81,6 +81,9 @@ const createTokenHash = () => {
|
|||
* @returns {Promise<void>}
|
||||
*/
|
||||
const sendVerificationEmail = async (user) => {
|
||||
const appConfig = await getAppConfig();
|
||||
const emailVerificationExpiry = appConfig?.registration?.emailVerificationExpiry || 900;
|
||||
|
||||
const [verifyToken, hash] = createTokenHash();
|
||||
|
||||
const verificationLink = `${
|
||||
|
|
@ -103,7 +106,7 @@ const sendVerificationEmail = async (user) => {
|
|||
email: user.email,
|
||||
token: hash,
|
||||
createdAt: Date.now(),
|
||||
expiresIn: 900,
|
||||
expiresIn: emailVerificationExpiry,
|
||||
});
|
||||
|
||||
logger.info(`[sendVerificationEmail] Verification link issued. [Email: ${user.email}]`);
|
||||
|
|
@ -472,6 +475,9 @@ const setOpenIDAuthTokens = (tokenset, res, userId) => {
|
|||
const resendVerificationEmail = async (req) => {
|
||||
try {
|
||||
const { email } = req.body;
|
||||
const appConfig = await getAppConfig();
|
||||
const emailVerificationExpiry = appConfig?.registration?.emailVerificationExpiry || 900;
|
||||
|
||||
await deleteTokens({ email });
|
||||
const user = await findUser({ email }, 'email _id name');
|
||||
|
||||
|
|
@ -503,7 +509,7 @@ const resendVerificationEmail = async (req) => {
|
|||
email: user.email,
|
||||
token: hash,
|
||||
createdAt: Date.now(),
|
||||
expiresIn: 900,
|
||||
expiresIn: emailVerificationExpiry,
|
||||
});
|
||||
|
||||
logger.info(`[resendVerificationEmail] Verification link issued. [Email: ${user.email}]`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue