Package updates

update types in /api/users/login to avoid tsc error
This commit is contained in:
Aaron William Po
2023-04-04 22:07:04 -04:00
parent 796a5fce3f
commit fe683282b2
3 changed files with 1846 additions and 1818 deletions

View File

@@ -9,6 +9,7 @@ import { z } from 'zod';
import LoginValidationSchema from '@/services/User/schema/LoginValidationSchema';
import { UserExtendedNextApiRequest } from '@/config/auth/types';
import validateRequest from '@/config/nextConnect/middleware/validateRequest';
import GetUserSchema from '@/services/User/schema/GetUserSchema';
const router = createRouter<
UserExtendedNextApiRequest,
@@ -20,14 +21,18 @@ router.post(
expressWrapper(async (req, res, next) => {
passport.initialize();
passport.use(localStrat);
passport.authenticate('local', { session: false }, (error, token) => {
if (error) {
next(error);
return;
}
req.user = token;
next();
})(req, res, next);
passport.authenticate(
'local',
{ session: false },
(error: unknown, token: z.infer<typeof GetUserSchema>) => {
if (error) {
next(error);
return;
}
req.user = token;
next();
},
)(req, res, next);
}),
async (req, res) => {
const user = req.user!;