management_cli.py 760 Bytes
Newer Older
Davide Depau's avatar
Davide Depau committed
1
import crypt
2

JackV's avatar
JackV committed
3
import click
Davide Depau's avatar
Davide Depau committed
4

JackV's avatar
JackV committed
5
from . import app, redis_store, redis_key_for_user
Davide Depau's avatar
Davide Depau committed
6
7


JackV's avatar
JackV committed
8
@app.cli.command()
Davide Depau's avatar
Davide Depau committed
9
10
11
12
13
@click.argument("username")
@click.option("--passwd", "-p", prompt="Password", help="Password", hide_input=True)
def adduser(username, passwd):
    """Add UUS admin user"""
    cryptpwd = crypt.crypt(passwd)
JackV's avatar
JackV committed
14
    redis_store.set(redis_key_for_user(username), cryptpwd)
Davide Depau's avatar
Davide Depau committed
15
16


JackV's avatar
JackV committed
17
@app.cli.command()
Davide Depau's avatar
Davide Depau committed
18
19
20
21
22
23
24
@click.argument("username")
@click.option("--passwd", "-p", prompt="Password", help="Password", hide_input=True)
def passwd(username, passwd):
    """Change UUS admin user password"""
    adduser(username, passwd)


JackV's avatar
JackV committed
25
@app.cli.command()
Davide Depau's avatar
Davide Depau committed
26
27
28
@click.argument("username")
def deluser(username):
    """Delete UUS admin user"""
JackV's avatar
JackV committed
29
    redis_store.delete(redis_key_for_user(username))