Compare commits
1 Commits
b440119334
...
5e16a90447
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e16a90447 |
@@ -156,11 +156,22 @@ update_admin_password() {
|
||||
local http_code
|
||||
local response
|
||||
|
||||
# Stalwart requires password to be hashed with SHA-512 crypt
|
||||
local hashed_password
|
||||
if command -v mkpasswd >/dev/null 2>&1; then
|
||||
hashed_password=$(mkpasswd -m sha-512 "$new_password")
|
||||
elif command -v openssl >/dev/null 2>&1; then
|
||||
hashed_password=$(openssl passwd -6 "$new_password")
|
||||
else
|
||||
log_error "Neither mkpasswd nor openssl available for password hashing"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Stalwart uses /api/account/auth with array format
|
||||
response=$(curl -s -w "\n%{http_code}" -X POST "${API_URL}/account/auth" \
|
||||
-u "admin:${current_password}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "[{\"type\":\"setPassword\",\"password\":\"${new_password}\"}]" 2>&1)
|
||||
-d "[{\"type\":\"setPassword\",\"password\":\"${hashed_password}\"}]" 2>&1)
|
||||
|
||||
http_code=$(echo "$response" | tail -n 1)
|
||||
response=$(echo "$response" | sed '$d')
|
||||
|
||||
Reference in New Issue
Block a user