sharedsecret

This commit is contained in:
Wolfgang Hottgenroth 2021-04-29 16:40:58 +02:00
parent b16be4f98f
commit 6f9ae7bcb2
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
2 changed files with 5 additions and 5 deletions

View File

@ -2,7 +2,7 @@ CREATE SEQUENCE device_s START WITH 1 INCREMENT BY 1;
CREATE TABLE device_t ( CREATE TABLE device_t (
id integer PRIMARY KEY DEFAULT NEXTVAL('device_s'), id integer PRIMARY KEY DEFAULT NEXTVAL('device_s'),
deviceid varchar(16) NOT NULL, deviceid varchar(16) UNIQUE NOT NULL,
sharedsecret varchar(31) NOT NULL, sharedsecret varchar(31) NOT NULL,
active boolean NOT NULL DEFAULT false active boolean NOT NULL DEFAULT false
); );

View File

@ -152,12 +152,12 @@ t_device *findDevice(t_commonHandle *handle, char *deviceId) {
logmsg(LOG_INFO, "findDevice query fails, database returns %s", PQresStatus(execStatus)); logmsg(LOG_INFO, "findDevice query fails, database returns %s", PQresStatus(execStatus));
} else { } else {
int ntuples = PQntuples(res2); int ntuples = PQntuples(res2);
if (ntuples == 0) { if (ntuples == 1) {
logmsg(LOG_ERR, "no device found");
} else if (ntuples == 1) {
logmsg(LOG_DEBUG, "device found"); logmsg(LOG_DEBUG, "device found");
char *sharedsecret = PQgetvalue(res2, 0, 0);
logmsg(LOG_DEBUG, "found sharedsecret is %s", sharedsecret);
} else { } else {
logmsg(LOG_ERR, "strange number of devices found: %d", ntuples); logmsg(LOG_ERR, "no device found");
} }
} }
PQclear(res2); PQclear(res2);