fix imports

This commit is contained in:
Luna 2019-10-25 16:01:48 -03:00
parent 91d70d2c41
commit c765cd7fe0
5 changed files with 31 additions and 11 deletions

View File

@ -19,8 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import base64
import binascii
from random import randint
from typing import Tuple
import bcrypt
from itsdangerous import TimestampSigner, BadSignature
@ -28,7 +26,6 @@ from logbook import Logger
from quart import request, current_app as app
from litecord.errors import Forbidden, Unauthorized
from litecord.snowflake import get_snowflake
from litecord.enums import UserFlags

View File

@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from os import urandom
from asyncpg import UniqueViolationError
from quart import Blueprint, jsonify, request, current_app as app
@ -41,6 +40,7 @@ from litecord.common.users import (
delete_user,
check_username_usage,
roll_discrim,
user_disconnect,
)
bp = Blueprint("user", __name__)
@ -438,11 +438,6 @@ async def _get_mentions():
return jsonify(res)
def rand_hex(length: int = 8) -> str:
"""Generate random hex characters."""
return urandom(length).hex()[:length]
@bp.route("/@me/delete", methods=["POST"])
async def delete_account():
"""Delete own account.

View File

@ -1,3 +1,23 @@
"""
Litecord
Copyright (C) 2018-2019 Luna Mendes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import logging
from random import randint
from typing import Tuple, Optional
@ -7,6 +27,9 @@ from asyncpg import UniqueViolationError
from ..snowflake import get_snowflake
from ..errors import BadRequest
from ..auth import hash_data
from ..utils import rand_hex
log = logging.getLogger(__name__)
async def mass_user_update(user_id):

View File

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import asyncio
import json
import secrets
from typing import Any, Iterable, Optional, Sequence, List, Dict, Union
from logbook import Logger
@ -284,3 +285,8 @@ def query_tuple_from_args(args: dict, limit: int) -> tuple:
before = int(args["after"])
return before, after
def rand_hex(length: int = 8) -> str:
"""Generate random hex characters."""
return secrets.token_hex(length)[:length]

View File

@ -30,10 +30,9 @@ from tests.common import email, TestClient
from run import app as main_app, set_blueprints
from litecord.auth import create_user
from litecord.common.users import create_user, delete_user
from litecord.enums import UserFlags
from litecord.blueprints.auth import make_token
from litecord.blueprints.users import delete_user
@pytest.fixture(name="app")