Find last password update for a user

Hello,

In order to implement a password renew policy in for the mattermost instance in my compagny, I’m looking for a way to get the last password update for each user. I founded this value in the database but i’m looking for a way to get this value from API. I did not find an api that gives me this information. Can you help me ?

Hey @360 ,

the API supports that, but you need to run through the active users first. Here’s a small bash oneliner that prints all usernames with their unix timestamp representation of the last password change (null if they never changed the password):

# for user in $(curl -sX GET -H "Authorization: Token $TOKEN" http://localhost:8065/api/v4/users?active=true  | jq -r .[].id); do curl -sX GET -H "Authorization: Token $TOKEN" http://localhost:8065/api/v4/users/$user | jq -jr '.|.username,": ",.last_password_update,"\n"'; done
a29838: null
aaron.medina: null
aggmail: null
anne.stone: null
appsbot: null
ashley.berry: null
boards: null
bofh: 1667722939665
[...]