Commit 1935519d authored by Michael Ochmann's avatar Michael Ochmann

fixed bug, where "admin" suddently was a keyword in mysql SQL syntax

parent fccbc0ed
......@@ -44,7 +44,7 @@ class DatabaseHandler {
pin VARCHAR(128) NOT NULL,
password VARCHAR(128) NOT NULL,
salt VARCHAR(32) NOT NULL,
admin TINYINT NULL
superuser TINYINT(1) NULL
);
CREATE TABLE IF NOT EXISTS sales (
......@@ -139,4 +139,4 @@ DatabaseHandler.Defaults = {
DB : "casheer"
};
module.exports = DatabaseHandler;
\ No newline at end of file
module.exports = DatabaseHandler;
const Endpoint = require("./Endpoint");
const Server = require("../Server");
const DB = require("../../DatabaseHandler");
const Server = require("../Server");
const DB = require("../../DatabaseHandler");
const Response = require("../Response");
const Std = require("../../Std");
class AddUser extends Endpoint {
constructor(api) {
......@@ -16,7 +17,7 @@ class AddUser extends Endpoint {
"rft",
"pin",
"password",
"admin"
"superuser"
]);
if (correct !== true) {
response.send(Server.Error(
......@@ -28,9 +29,9 @@ class AddUser extends Endpoint {
}
this.db.query(DB.Prepare(`
INSERT INTO users (display_name, rft, pin, password, admin)
VALUES (?, ?, ?, ?, ?)
`, [body.display_name, body.rft, body.pin, body.password, body.admin]), (rows, error) => {
INSERT INTO users (display_name, rft, salt, pin, password, superuser)
VALUES (?, ?, ?, ?, ?, ?)
`, [body.display_name, body.rft, "4d18db80e353e526ad6d42a62aaa29be", body.pin, body.password, body.superuser]), (rows, error) => {
if (error) {
let msg;
switch (error.code) {
......@@ -41,7 +42,7 @@ class AddUser extends Endpoint {
msg = "database error";
break;
}
response.send(Server.Error("duplicate user", Response.ErrorCode.DATABASE_ERROR).string());
response.send(Server.Error(msg, Response.ErrorCode.DATABASE_ERROR).string());
return;
}
response.send(new Response({
......@@ -51,4 +52,4 @@ class AddUser extends Endpoint {
}
}
module.exports = AddUser;
\ No newline at end of file
module.exports = AddUser;
{}
\ No newline at end of file
This diff is collapsed.
......@@ -19,6 +19,7 @@
"body-parser": "^1.18.3",
"chalk": "^2.3.0",
"express": "^4.16.3",
"mysql": "^2.15.0"
"mysql": "^2.15.0",
"mysql2": "^1.6.4"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment