mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2025-12-24 02:39:18 -05:00
Merge pull request #136 from NicolaiVdS/email-validation-and-requirement
feat(userprofile): email requirement and validation + import user button overhaul
This commit is contained in:
@@ -9,6 +9,7 @@ import { Permission } from '../lib/permissions';
|
||||
import { getSettings } from '../lib/settings';
|
||||
import logger from '../logger';
|
||||
import { isAuthenticated } from '../middleware/auth';
|
||||
import * as EmailValidator from 'email-validator';
|
||||
|
||||
const authRoutes = Router();
|
||||
|
||||
@@ -24,6 +25,16 @@ authRoutes.get('/me', isAuthenticated(), async (req, res) => {
|
||||
where: { id: req.user.id },
|
||||
});
|
||||
|
||||
// check if email is required in settings and if user has an valid email
|
||||
const settings = await getSettings();
|
||||
if (
|
||||
settings.notifications.agents.email.options.userEmailRequired &&
|
||||
!EmailValidator.validate(user.email)
|
||||
) {
|
||||
user.warnings.push('userEmailRequired');
|
||||
logger.warn(`User ${user.username} has no valid email address`);
|
||||
}
|
||||
|
||||
return res.status(200).json(user);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user