(socket : DockgeSocket, currentPassword : unknown)
| 84 | } |
| 85 | |
| 86 | export async function doubleCheckPassword(socket : DockgeSocket, currentPassword : unknown) { |
| 87 | if (typeof currentPassword !== "string") { |
| 88 | throw new Error("Wrong data type?"); |
| 89 | } |
| 90 | |
| 91 | let user = await R.findOne("user", " id = ? AND active = 1 ", [ |
| 92 | socket.userID, |
| 93 | ]); |
| 94 | |
| 95 | if (!user || !verifyPassword(currentPassword, user.password)) { |
| 96 | throw new Error("Incorrect current password"); |
| 97 | } |
| 98 | |
| 99 | return user; |
| 100 | } |
| 101 | |
| 102 | export function fileExists(file : string) { |
| 103 | return fs.promises.access(file, fs.constants.F_OK) |
no test coverage detected