|
|
|
@ -108,10 +108,11 @@ exports.adminLogin = async (request, reply) => {
|
|
|
|
|
return reply.status(401).send({ message: 'Invalid phone number or password' });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Generate a JWT token for the authenticated admin
|
|
|
|
|
const token = jwt.sign({ phone: admin.phone, role: 'admin' }, JWT_SECRET, { expiresIn: '1h' });
|
|
|
|
|
|
|
|
|
|
return reply.send({ token });
|
|
|
|
|
return reply.send({ token, admin });
|
|
|
|
|
} catch (err) {
|
|
|
|
|
reply.status(500).send({ message: err.message });
|
|
|
|
|
}
|
|
|
|
|