-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathadmin.sh
executable file
·53 lines (45 loc) · 1.26 KB
/
admin.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. "${SCRIPT_DIR}/helpers.sh"
load_env
policiesupdate() {
docker exec -i $(container_name worker-1) python3 <<EOF
import asyncio
from api import settings, utils, schemes
async def main():
settings.settings_ctx.set(settings.Settings())
await settings.init()
policies = await utils.policies.get_setting(schemes.Policy)
for key, value in $1.items():
setattr(policies, key, value)
await utils.policies.set_setting(policies)
asyncio.run(main())
EOF
}
sqlquery() {
docker exec $(container_name database-1) psql -U postgres -d bitcart -c "$*"
}
case "$1" in
disable-multifactor)
sqlquery "UPDATE users SET tfa_enabled=false, fido2_devices='{}' WHERE email='$2';"
;;
disable-captcha)
policiesupdate "{\"enable_captcha\": False}"
;;
set-user-admin)
sqlquery "UPDATE users SET is_superuser=true WHERE email='$2';"
;;
reset-server-policy)
sqlquery "DELETE FROM settings WHERE name='policy';"
;;
*)
echo "Usage: $0 [command]"
echo
echo "Commands:"
echo " disable-captcha"
echo " disable-multifactor <email>"
echo " set-user-admin <email>"
echo " reset-server-policy"
;;
esac
exit 0