Last active
January 16, 2016 14:11
-
-
Save filterfish/9e1250d8811a3e73a727 to your computer and use it in GitHub Desktop.
Simple script to reset a user's password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
username=$1 | |
password=$2 | |
db=synapse-homeserver | |
[[ -z $username ]] || [[ -z $password ]] && { print "usage: $0 <username> <password>"; exit; } | |
password_hash=$(python -c "import bcrypt; print bcrypt.hashpw(\"$password\", bcrypt.gensalt())") | |
echo $password_hash | |
psql -c "update users set password_hash = '$password_hash' where name = '$username'" $db |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment