email can't be null, username removed since email can't be null

This commit is contained in:
jackiettran
2025-11-24 15:41:35 -05:00
parent 6aac929ec1
commit 532f3014df
6 changed files with 59 additions and 85 deletions

View File

@@ -95,7 +95,7 @@ router.get('/posts', optionalAuth, async (req, res) => {
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName']
attributes: ['id', 'firstName', 'lastName']
},
{
model: PostTag,
@@ -170,12 +170,12 @@ router.get('/posts/:id', optionalAuth, async (req, res) => {
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName', 'role']
attributes: ['id', 'firstName', 'lastName', 'role']
},
{
model: User,
as: 'closer',
attributes: ['id', 'username', 'firstName', 'lastName', 'role'],
attributes: ['id', 'firstName', 'lastName', 'role'],
required: false
},
{
@@ -191,7 +191,7 @@ router.get('/posts/:id', optionalAuth, async (req, res) => {
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName', 'role']
attributes: ['id', 'firstName', 'lastName', 'role']
}
]
}
@@ -335,7 +335,7 @@ router.post('/posts', authenticateToken, uploadForumPostImages, async (req, res)
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName']
attributes: ['id', 'firstName', 'lastName']
},
{
model: PostTag,
@@ -524,7 +524,7 @@ router.put('/posts/:id', authenticateToken, async (req, res) => {
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName']
attributes: ['id', 'firstName', 'lastName']
},
{
model: PostTag,
@@ -622,7 +622,7 @@ router.patch('/posts/:id/status', authenticateToken, async (req, res) => {
(async () => {
try {
const closerUser = await User.findByPk(req.user.id, {
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
attributes: ['id', 'firstName', 'lastName', 'email']
});
const postWithAuthor = await ForumPost.findByPk(post.id, {
@@ -630,7 +630,7 @@ router.patch('/posts/:id/status', authenticateToken, async (req, res) => {
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
attributes: ['id', 'firstName', 'lastName', 'email']
}
]
});
@@ -702,12 +702,12 @@ router.patch('/posts/:id/status', authenticateToken, async (req, res) => {
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName']
attributes: ['id', 'firstName', 'lastName']
},
{
model: User,
as: 'closer',
attributes: ['id', 'username', 'firstName', 'lastName'],
attributes: ['id', 'firstName', 'lastName'],
required: false
},
{
@@ -790,13 +790,13 @@ router.patch('/posts/:id/accept-answer', authenticateToken, async (req, res) =>
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
attributes: ['id', 'firstName', 'lastName', 'email']
}
]
});
const postAuthor = await User.findByPk(req.user.id, {
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
attributes: ['id', 'firstName', 'lastName', 'email']
});
const postWithAuthor = await ForumPost.findByPk(post.id, {
@@ -804,7 +804,7 @@ router.patch('/posts/:id/accept-answer', authenticateToken, async (req, res) =>
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
attributes: ['id', 'firstName', 'lastName', 'email']
}
]
});
@@ -882,7 +882,7 @@ router.patch('/posts/:id/accept-answer', authenticateToken, async (req, res) =>
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName']
attributes: ['id', 'firstName', 'lastName']
},
{
model: PostTag,
@@ -972,7 +972,7 @@ router.post('/posts/:id/comments', authenticateToken, uploadForumCommentImages,
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
attributes: ['id', 'firstName', 'lastName', 'email']
}
]
});
@@ -984,7 +984,7 @@ router.post('/posts/:id/comments', authenticateToken, uploadForumCommentImages,
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
attributes: ['id', 'firstName', 'lastName', 'email']
}
]
});
@@ -1027,7 +1027,7 @@ router.post('/posts/:id/comments', authenticateToken, uploadForumCommentImages,
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName', 'email']
attributes: ['id', 'firstName', 'lastName', 'email']
}
],
group: ['ForumComment.authorId', 'author.id']
@@ -1102,7 +1102,7 @@ router.put('/comments/:id', authenticateToken, async (req, res) => {
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName']
attributes: ['id', 'firstName', 'lastName']
}
]
});
@@ -1177,7 +1177,7 @@ router.get('/my-posts', authenticateToken, async (req, res) => {
{
model: User,
as: 'author',
attributes: ['id', 'username', 'firstName', 'lastName']
attributes: ['id', 'firstName', 'lastName']
},
{
model: PostTag,
@@ -1294,7 +1294,7 @@ router.delete('/admin/posts/:id', authenticateToken, requireAdmin, async (req, r
(async () => {
try {
const admin = await User.findByPk(req.user.id, {
attributes: ['id', 'username', 'firstName', 'lastName']
attributes: ['id', 'firstName', 'lastName']
});
if (post.author && admin) {
@@ -1422,7 +1422,7 @@ router.delete('/admin/comments/:id', authenticateToken, requireAdmin, async (req
(async () => {
try {
const admin = await User.findByPk(req.user.id, {
attributes: ['id', 'username', 'firstName', 'lastName']
attributes: ['id', 'firstName', 'lastName']
});
if (comment.author && admin && post) {