fix: correct CFScript syntax in login endpoint
- Fix cflock to lock in CFScript - Remove var keyword at top-level scope (outside functions) - Fixes 500 error and now returns proper JSON responses
This commit is contained in:
parent
363964d9c6
commit
41122fc0fb
1 changed files with 6 additions and 6 deletions
|
|
@ -42,16 +42,16 @@ function normalizeUsername(required string u) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = readJsonBody();
|
data = readJsonBody();
|
||||||
var username = structKeyExists(data, "username") ? normalizeUsername("" & data.username) : "";
|
username = structKeyExists(data, "username") ? normalizeUsername("" & data.username) : "";
|
||||||
var password = structKeyExists(data, "password") ? ("" & data.password) : "";
|
password = structKeyExists(data, "password") ? ("" & data.password) : "";
|
||||||
|
|
||||||
if (!len(username) || !len(password)) {
|
if (!len(username) || !len(password)) {
|
||||||
apiAbort({ "OK": false, "ERROR": "missing_fields" });
|
apiAbort({ "OK": false, "ERROR": "missing_fields" });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var q = queryExecute(
|
q = queryExecute(
|
||||||
"
|
"
|
||||||
SELECT UserID, UserFirstName
|
SELECT UserID, UserFirstName
|
||||||
FROM Users
|
FROM Users
|
||||||
|
|
@ -77,7 +77,7 @@ try {
|
||||||
apiAbort({ "OK": false, "ERROR": "bad_credentials" });
|
apiAbort({ "OK": false, "ERROR": "bad_credentials" });
|
||||||
}
|
}
|
||||||
|
|
||||||
var token = replace(createUUID(), "-", "", "all");
|
token = replace(createUUID(), "-", "", "all");
|
||||||
|
|
||||||
queryExecute(
|
queryExecute(
|
||||||
"INSERT INTO UserTokens (UserID, Token) VALUES (?, ?)",
|
"INSERT INTO UserTokens (UserID, Token) VALUES (?, ?)",
|
||||||
|
|
@ -89,7 +89,7 @@ try {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Optional: also set session for browser tools
|
// Optional: also set session for browser tools
|
||||||
cflock timeout="15" throwontimeout="yes" type="exclusive" scope="session" {
|
lock timeout="15" throwontimeout="yes" type="exclusive" scope="session" {
|
||||||
session.UserID = q.UserID;
|
session.UserID = q.UserID;
|
||||||
}
|
}
|
||||||
request.UserID = q.UserID;
|
request.UserID = q.UserID;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue