Compare commits
1 Commits
5e16a90447
...
b440119334
| Author | SHA1 | Date | |
|---|---|---|---|
| b440119334 |
@@ -156,22 +156,11 @@ update_admin_password() {
|
|||||||
local http_code
|
local http_code
|
||||||
local response
|
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
|
# Stalwart uses /api/account/auth with array format
|
||||||
response=$(curl -s -w "\n%{http_code}" -X POST "${API_URL}/account/auth" \
|
response=$(curl -s -w "\n%{http_code}" -X POST "${API_URL}/account/auth" \
|
||||||
-u "admin:${current_password}" \
|
-u "admin:${current_password}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "[{\"type\":\"setPassword\",\"password\":\"${hashed_password}\"}]" 2>&1)
|
-d "[{\"type\":\"setPassword\",\"password\":\"${new_password}\"}]" 2>&1)
|
||||||
|
|
||||||
http_code=$(echo "$response" | tail -n 1)
|
http_code=$(echo "$response" | tail -n 1)
|
||||||
response=$(echo "$response" | sed '$d')
|
response=$(echo "$response" | sed '$d')
|
||||||
|
|||||||
Reference in New Issue
Block a user