[Update] 添加禁用用户mfa脚本

pull/1819/head
ibuler 2018-09-12 11:36:27 +08:00
parent 0eda8865e6
commit 5bb867d10d
1 changed files with 24 additions and 0 deletions

24
utils/disable_user_mfa.py Normal file
View File

@ -0,0 +1,24 @@
#!/bin/bash
#
username=$1
if [ -z "${username}" ];then
echo "No username specify, exit"
exit 1
fi
function disable_user_mfa() {
python ../apps/manage.py shell << EOF
import sys
from users.models import User
user = User.objects.filter(username="${username}")
if not user:
print("No user found")
sys.exit(1)
user.update(otp_level=0)
print("Disable user ${username} success")
EOF
}
disable_user_mfa