Compare commits
1 Commits
306ab9af90
...
b89d0f5aa1
| Author | SHA1 | Date | |
|---|---|---|---|
| b89d0f5aa1 |
@@ -141,16 +141,27 @@ authenticate() {
|
|||||||
|
|
||||||
local response
|
local response
|
||||||
local token
|
local token
|
||||||
|
local http_code
|
||||||
|
|
||||||
response=$(curl -sf -X POST "${API_URL}/authenticate" \
|
# Try authentication with "account" field (Stalwart uses "account" not "login")
|
||||||
|
response=$(curl -s -w "\n%{http_code}" -X POST "${API_URL}/authenticate" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"login\":\"admin\",\"password\":\"${password}\"}" 2>&1) || {
|
-d "{\"account\":\"admin\",\"password\":\"${password}\"}" 2>&1)
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
token=$(echo "$response" | jq -r '.token // empty' 2>/dev/null)
|
http_code=$(echo "$response" | tail -n 1)
|
||||||
|
response=$(echo "$response" | sed '$d')
|
||||||
|
|
||||||
|
if [ "$http_code" != "200" ]; then
|
||||||
|
log_error "Authentication failed with HTTP $http_code"
|
||||||
|
log_error "Response: $response"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
token=$(echo "$response" | jq -r '.data // empty' 2>/dev/null)
|
||||||
|
|
||||||
if [ -z "$token" ]; then
|
if [ -z "$token" ]; then
|
||||||
|
log_error "No token in response"
|
||||||
|
log_error "Response: $response"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user