Compare commits
1 Commits
b89d0f5aa1
...
306ab9af90
| Author | SHA1 | Date | |
|---|---|---|---|
| 306ab9af90 |
@@ -141,27 +141,16 @@ authenticate() {
|
|||||||
|
|
||||||
local response
|
local response
|
||||||
local token
|
local token
|
||||||
local http_code
|
|
||||||
|
|
||||||
# Try authentication with "account" field (Stalwart uses "account" not "login")
|
response=$(curl -sf -X POST "${API_URL}/authenticate" \
|
||||||
response=$(curl -s -w "\n%{http_code}" -X POST "${API_URL}/authenticate" \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"account\":\"admin\",\"password\":\"${password}\"}" 2>&1)
|
-d "{\"login\":\"admin\",\"password\":\"${password}\"}" 2>&1) || {
|
||||||
|
|
||||||
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
|
return 1
|
||||||
fi
|
}
|
||||||
|
|
||||||
token=$(echo "$response" | jq -r '.data // empty' 2>/dev/null)
|
token=$(echo "$response" | jq -r '.token // 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