management_cli.py 760 Bytes
Newer Older
Davide Depau's avatar
Davide Depau committed
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
import crypt

import click

from . import app, redis_store, redis_key_for_user


@app.cli.command()
@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)
    redis_store.set(redis_key_for_user(username), cryptpwd)


@app.cli.command()
@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)


@app.cli.command()
@click.argument("username")
def deluser(username):
    """Delete UUS admin user"""
    redis_store.delete(redis_key_for_user(username))