async def list_users(): """ Показать пользователей """ from helpers import db from helpers.config import Config from helpers.models.users import User c = Config.get_config() click.echo(click.style(str(User.get(100, 0, 'id', 'DESC')), fg='green')) if 'postgres' not in c: click.echo(click.style('Config error. Cant load DB postgres', fg='red')) # получаем драйвер БД по конфигу pg = await db.get_pg_engine(c.get('postgres')) click.echo(await db.many(pg, User.get(100, 0, 'id', 'DESC')))
async def check_user_login(user_login, user_password): from helpers import db from helpers.models.users import User from helpers.models.groups import Group click.echo( click.style(str( User.get(1, 0, where_=[ User.login == user_login, User.password == user_password ])), fg='green')) click.echo(await db.many( await db.autoconfig(), User.get( 1, 0, where_=[User.login == user_login, User.password == user_password])))
async def __check_credentials(db_engine, username, password): if username == SUPERADMIN_LOGIN and password == SUPERADMIN_PASS: return True # суперадмин ОКай! try: # у нас пока не будет хешей, ибо народ забывает пароли user = (await one( db_engine, User.get( 1, 0, where_=[User.login == username, User.password == password]))) print(user) except Exception as e: print(e) return False if user: return True return False