feat(dashboard): add aggregated dashboard stats API, robust logout, and warehouse seeders
deploy-chabokan / deploy (push) Canceled after 0s
deploy-chabokan / deploy (push) Canceled after 0s
This commit is contained in:
@@ -39,20 +39,26 @@ exports.loginUser = catchAsync(async (req, res, next) => {
|
||||
})
|
||||
|
||||
exports.logoutUser = catchAsync(async (req, res, next) => {
|
||||
res.cookie('belonging_token', '', {
|
||||
httpOnly: true,
|
||||
maxAge: 0,
|
||||
path: '/',
|
||||
})
|
||||
res.cookie('bm-token', '', {
|
||||
httpOnly: false,
|
||||
maxAge: 0,
|
||||
path: '/',
|
||||
})
|
||||
const isProduction = process.env.NODE_ENV === 'production'
|
||||
|
||||
// Clear default host cookies
|
||||
res.clearCookie('belonging_token', { path: '/' })
|
||||
res.clearCookie('bm-token', { path: '/' })
|
||||
res.clearCookie('jwt', { path: '/' })
|
||||
|
||||
// Clear domain cookies if in production or mbmanager domain
|
||||
if (isProduction || req.hostname.includes('mbmanager.ir')) {
|
||||
res.clearCookie('belonging_token', { domain: '.mbmanager.ir', path: '/' })
|
||||
res.clearCookie('bm-token', { domain: '.mbmanager.ir', path: '/' })
|
||||
res.clearCookie('jwt', { domain: '.mbmanager.ir', path: '/' })
|
||||
}
|
||||
|
||||
res.cookie('belonging_token', '', { maxAge: 0, expires: new Date(0), path: '/' })
|
||||
res.cookie('bm-token', '', { maxAge: 0, expires: new Date(0), path: '/' })
|
||||
|
||||
res.status(200).json({
|
||||
status: 'success',
|
||||
message: 'کاربر خارج شد',
|
||||
message: 'کاربر با موفقیت خارج شد',
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user