Set longer session times
This commit is contained in:
parent
6070e587c6
commit
792abdfaf6
@ -63,14 +63,14 @@ async function addHttpRoutes(app: Application) {
|
|||||||
try {
|
try {
|
||||||
loginAccountSchema.parse({ username, password });
|
loginAccountSchema.parse({ username, password });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return res.status(400).json({ message: error.errors[0].message });
|
return res.status(400).json({ message: error.errors[0]?.message });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userService = new UserService();
|
const userService = new UserService();
|
||||||
const user = await userService.login(username, password);
|
const user = await userService.login(username, password);
|
||||||
|
|
||||||
if (user) { //test
|
if (user) { //test
|
||||||
const token = jwt.sign({ id: user.id }, config.JWT_SECRET, { expiresIn: '1h' });
|
const token = jwt.sign({ id: user.id }, config.JWT_SECRET, { expiresIn: '4h' });
|
||||||
return res.status(200).json({ token });
|
return res.status(200).json({ token });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,14 +83,14 @@ async function addHttpRoutes(app: Application) {
|
|||||||
try {
|
try {
|
||||||
registerAccountSchema.parse({ username, password });
|
registerAccountSchema.parse({ username, password });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return res.status(400).json({ message: error.errors[0].message });
|
return res.status(400).json({ message: error.errors[0]?.message });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userService = new UserService();
|
const userService = new UserService();
|
||||||
const user = await userService.register(username, password);
|
const user = await userService.register(username, password);
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
const token = jwt.sign({ id: user.id }, config.JWT_SECRET, { expiresIn: '1h' });
|
const token = jwt.sign({ id: user.id }, config.JWT_SECRET, { expiresIn: '4h' });
|
||||||
return res.status(200).json({ token });
|
return res.status(200).json({ token });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user