Refactor authentication and token management: Update authController.js to use environment variable for JWT expiration. Enhance axios.js and store/index.js for improved token usability checks and cleanup on logout, ensuring a more robust authentication flow.
All checks were successful
Deploy miriamgemeinde / deploy (push) Successful in 6s
All checks were successful
Deploy miriamgemeinde / deploy (push) Successful in 6s
This commit is contained in:
@@ -82,7 +82,11 @@ exports.login = async (req, res) => {
|
||||
if (!user.active) {
|
||||
return res.status(403).json({ message: 'Benutzerkonto ist nicht aktiv' });
|
||||
}
|
||||
const token = jwt.sign({ id: user.id, name: user.name, email: user.email }, 'zTxVgptmPl9!_dr%xxx9999(dd)', { expiresIn: '1h' });
|
||||
const token = jwt.sign(
|
||||
{ id: user.id, name: user.name, email: user.email },
|
||||
'zTxVgptmPl9!_dr%xxx9999(dd)',
|
||||
{ expiresIn: process.env.JWT_EXPIRES_IN || '12h' }
|
||||
);
|
||||
return res.status(200).json({ message: 'Login erfolgreich', token, 'user': user });
|
||||
} catch (error) {
|
||||
return res.status(500).json({ message: 'Ein Fehler ist aufgetreten' });
|
||||
|
||||
Reference in New Issue
Block a user