forked from noxious/server
Set longer session times
This commit is contained in:
parent
6070e587c6
commit
792abdfaf6
@ -63,14 +63,14 @@ async function addHttpRoutes(app: Application) {
|
||||
try {
|
||||
loginAccountSchema.parse({ username, password });
|
||||
} 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 user = await userService.login(username, password);
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
@ -83,14 +83,14 @@ async function addHttpRoutes(app: Application) {
|
||||
try {
|
||||
registerAccountSchema.parse({ username, password });
|
||||
} 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 user = await userService.register(username, password);
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user