mirror of
https://git.isptech.ru/ISPsystem/isp-maintenance.git
synced 2025-09-13 21:43:08 +02:00
Update: access funcs
This commit is contained in:
@@ -38,16 +38,22 @@ def user():
|
||||
)
|
||||
def ls(all, admins):
|
||||
if all:
|
||||
user_cursor.echo_users(role='all')
|
||||
users = user_cursor.get_users(role='all')
|
||||
elif admins:
|
||||
user_cursor.echo_users(role='admin')
|
||||
users = user_cursor.get_users(role='admin')
|
||||
else:
|
||||
user_cursor.echo_users(role='all')
|
||||
users = user_cursor.get_users(role='all')
|
||||
# print users:
|
||||
user_cursor.echo_users(users)
|
||||
|
||||
|
||||
@user.command(help='Generate access key and return auth link(s)')
|
||||
@user.command(
|
||||
help='Generate an access key and return auth link(s)',
|
||||
no_args_is_help=True
|
||||
)
|
||||
@click.option(
|
||||
'--id',
|
||||
'_id',
|
||||
required=False,
|
||||
type=int,
|
||||
help='User id'
|
||||
@@ -62,7 +68,7 @@ def ls(all, admins):
|
||||
'--random',
|
||||
is_flag=True,
|
||||
required=False,
|
||||
help='Interactive mode, ignores other keys'
|
||||
help='Generate access key for the first available admin'
|
||||
)
|
||||
@click.option(
|
||||
'--interactive',
|
||||
@@ -70,24 +76,21 @@ def ls(all, admins):
|
||||
required=False,
|
||||
help='Interactive mode, ignores other keys'
|
||||
)
|
||||
def access(id, count, interactive, random):
|
||||
if id and not count:
|
||||
keys = user_cursor.get_access_keys(user=id, count=1)
|
||||
links = user_cursor.gen_access_links(keys)
|
||||
user_cursor.echo_access_links(links)
|
||||
elif id and count:
|
||||
keys = user_cursor.get_access_keys(user=id, count=count)
|
||||
links = user_cursor.gen_access_links(keys)
|
||||
user_cursor.echo_access_links(links)
|
||||
elif interactive:
|
||||
pass
|
||||
def access(_id, count, interactive, random):
|
||||
if _id and not count:
|
||||
keys = user_cursor.get_access_keys(user=_id, count=1)
|
||||
elif _id and count:
|
||||
keys = user_cursor.get_access_keys(user=_id, count=count)
|
||||
elif random:
|
||||
admin = user_cursor.get_first_random_admin()
|
||||
keys = user_cursor.get_access_keys(user=admin.get('id', 3), count=1)
|
||||
links = user_cursor.gen_access_links(keys)
|
||||
user_cursor.echo_access_links(links)
|
||||
keys = user_cursor.get_access_keys(user=admin.get('id', 3))
|
||||
elif interactive:
|
||||
user_cursor.gen_access_links_interactive()
|
||||
return # exit from func
|
||||
else:
|
||||
pass
|
||||
links = user_cursor.gen_access_links(keys)
|
||||
user_cursor.echo_access_links(links)
|
||||
|
||||
|
||||
@user.command(help='Generate API token for mgrctl user')
|
||||
|
Reference in New Issue
Block a user