mirror of
https://github.com/louislam/dockge.git
synced 2026-05-22 06:22:17 +00:00
wip
This commit is contained in:
@@ -3,6 +3,8 @@ import { Terminal } from "./terminal";
|
||||
import { randomBytes } from "crypto";
|
||||
import { log } from "./log";
|
||||
import { ERROR_TYPE_VALIDATION } from "./util-common";
|
||||
import { R } from "redbean-node";
|
||||
import { verifyPassword } from "./password-hash";
|
||||
|
||||
export interface DockgeSocket extends Socket {
|
||||
userID: number;
|
||||
@@ -57,3 +59,19 @@ export function callbackError(error : unknown, callback : unknown) {
|
||||
log.debug("console", "Unknown error: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function doubleCheckPassword(socket : DockgeSocket, currentPassword : unknown) {
|
||||
if (typeof currentPassword !== "string") {
|
||||
throw new Error("Wrong data type?");
|
||||
}
|
||||
|
||||
let user = await R.findOne("user", " id = ? AND active = 1 ", [
|
||||
socket.userID,
|
||||
]);
|
||||
|
||||
if (!user || !verifyPassword(currentPassword, user.password)) {
|
||||
throw new Error("Incorrect current password");
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user