Enhance login functionality in AuthController and AuthService; add optional action parameter to login method, execute corresponding actions post-login, and handle action warnings. Update frontend components to trigger data refresh on successful login and display warnings if actions fail. Adjust SQL query in TimeEntryService for improved grouping.
This commit is contained in:
@@ -40,7 +40,7 @@ class AuthController {
|
||||
*/
|
||||
async login(req, res) {
|
||||
try {
|
||||
const { email, password } = req.body;
|
||||
const { email, password, action } = req.body;
|
||||
|
||||
if (!email || !password) {
|
||||
return res.status(400).json({
|
||||
@@ -49,14 +49,21 @@ class AuthController {
|
||||
});
|
||||
}
|
||||
|
||||
const result = await authService.login(email, password);
|
||||
const result = await authService.login(email, password, action);
|
||||
|
||||
res.json({
|
||||
const response = {
|
||||
success: true,
|
||||
message: 'Login erfolgreich',
|
||||
token: result.token,
|
||||
user: result.user
|
||||
});
|
||||
};
|
||||
|
||||
// Füge Warnung hinzu, falls vorhanden
|
||||
if (result.actionWarning) {
|
||||
response.actionWarning = result.actionWarning;
|
||||
}
|
||||
|
||||
res.json(response);
|
||||
} catch (error) {
|
||||
console.error('Login-Fehler:', error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user