;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

This commit is contained in:
2024-10-27 05:45:12 +03:00
parent 3388da7280
commit 09b5106538
20 changed files with 82 additions and 76 deletions

View File

@@ -5,14 +5,14 @@ import bcrypt from 'bcrypt';
class UserService {
async create(username, password) {
await db.query("INSERT INTO users (username, password) VALUES ($1, $2)", [username, bcrypt.hashSync(password, 12)]).catch((e) => {
errorHandler(e, "user")
errorHandler(e, "user");
})
return statuses.ok
return statuses.ok;
}
async getByUsername(username) {
let user = (await db.query("SELECT * FROM Users WHERE username = $1", [username])).rows
if (user == undefined) return statuses.not_found
let user = (await db.query("SELECT * FROM Users WHERE username = $1", [username])).rows;
if (user == undefined) return statuses.not_found;
return (user[0]);
}