mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 17:59:25 +00:00
Catch database errors and prevent them from crashing the app
This commit is contained in:
@@ -72,9 +72,7 @@ class PasswordReset {
|
||||
where userId = ?;
|
||||
`;
|
||||
|
||||
await conn.runQuery(sql, [ u.id ]);
|
||||
|
||||
conn.close();
|
||||
let result = await conn.runQuery(sql, [ u.id ]);
|
||||
|
||||
const [ nonce, token ] = await PasswordReset.hashToken(u);
|
||||
|
||||
@@ -93,13 +91,18 @@ class PasswordReset {
|
||||
values (?, ?, ?, FROM_UNIXTIME(?));
|
||||
`;
|
||||
|
||||
await conn.runQuery(sql, [
|
||||
result = await conn.runQuery(sql, [
|
||||
u.id,
|
||||
token,
|
||||
nonce,
|
||||
expires
|
||||
]);
|
||||
|
||||
if (!result)
|
||||
throw new Error('Could not create password reset');
|
||||
|
||||
conn.close();
|
||||
|
||||
return new PasswordReset(u.id, token);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user