Change user password via API

Started by become, May 30, 2017, 04:48:03 PM

Previous topic - Next topic

become

I want to write API function for change user password.
I see php files are encrypted so I do not know how start with it.
Any help ?

yokowasis

Quote from: become on May 30, 2017, 04:48:03 PM
I want to write API function for change user password.
I see php files are encrypted so I do not know how start with it.
Any help ?

users password store in /etc/shadow



I think

darkness

Yep. So you need to get the plain password, to crypt it the same way CentOS do, replace it in /etc/shadow and reload the password db of CentOS(this is by memory from FreeBSD, may be on Linux you don`t need to reload it after changes).
UNIX is a very simple OS, but you have to be a GENIUS to understand it ...

André Bastos

Quote from: become on May 30, 2017, 04:48:03 PM
I want to write API function for change user password.
I see php files are encrypted so I do not know how start with it.
Any help ?

Update the API details: IP, key, and username/password :)

API_IP=
API_KEY=
API_URL_ACCOUNT="https://${API_IP}:2304/v1/account"
API_URL_CHANGEPASS="https://${API_IP}:2304/v1/changepass"

USERNAME=
NEW_PASSWORD=

API_RESPONSE=$(curl -k -s -X POST "$API_URL_CHANGEPASS" \
  -F "key=$API_KEY" \
  -F "action=update" \
  -F "user=$USERNAME" \
  -F "pass=$NEW_PASSWORD")


if [ -z "$API_RESPONSE" ]; then
    echo -e "erroR"
else
    echo -e "$API_RESPONSE"
fi
André Bastos
ISBrasil Hospedagem de Site