mirror of https://gitlab.com/litecord/litecord.git
add admin_api.{users, instance_invites} blueprints
- admin_schemas: add USER_CREATE
This commit is contained in:
parent
76048f3abc
commit
5fb27c04a2
|
|
@ -40,3 +40,9 @@ FEATURES = {
|
||||||
'schema': {'coerce': lambda x: Feature(x)}
|
'schema': {'coerce': lambda x: Feature(x)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
USER_CREATE = {
|
||||||
|
'username': {'type': 'username', 'required': True},
|
||||||
|
'email': {'type': 'email', 'required': True},
|
||||||
|
'password': {'type': 'string', 'minlength': 5, 'required': True},
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,5 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from .voice import bp as voice
|
from .voice import bp as voice
|
||||||
from .features import bp as features
|
from .features import bp as features
|
||||||
from .guilds import bp as guilds
|
from .guilds import bp as guilds
|
||||||
|
from .users import bp as users
|
||||||
|
from .instance_invites import bp as instance_invites
|
||||||
|
|
||||||
__all__ = ['voice', 'features', 'guilds']
|
__all__ = ['voice', 'features', 'guilds', 'users', 'instance_invites']
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
"""
|
||||||
|
|
||||||
|
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/>.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from quart import Blueprint, jsonify, current_app as app
|
||||||
|
|
||||||
|
from litecord.auth import admin_check
|
||||||
|
|
||||||
|
bp = Blueprint('instance_invites', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('', methods=['GET'])
|
||||||
|
async def _all_instance_invites():
|
||||||
|
await admin_check()
|
||||||
|
|
||||||
|
rows = await app.db.fetch("""
|
||||||
|
SELECT code, created_at, uses, max_uses
|
||||||
|
FROM instance_invites
|
||||||
|
""")
|
||||||
|
|
||||||
|
return jsonify([dict(row) for row in rows])
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
"""
|
||||||
|
|
||||||
|
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/>.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from quart import Blueprint, jsonify, current_app as app, request
|
||||||
|
|
||||||
|
from litecord.auth import admin_check
|
||||||
|
from litecord.blueprints.auth import create_user
|
||||||
|
from litecord.schemas import validate
|
||||||
|
from litecord.admin_schemas import USER_CREATE
|
||||||
|
|
||||||
|
bp = Blueprint('users_admin', __name__)
|
||||||
|
|
||||||
|
@bp.route('', methods=['POST'])
|
||||||
|
async def _create_user():
|
||||||
|
await admin_check()
|
||||||
|
|
||||||
|
j = validate(await request.get_json(), USER_CREATE)
|
||||||
|
|
||||||
|
user_id = await create_user(j['username'], j['email'], j['password'])
|
||||||
|
|
||||||
|
return jsonify(
|
||||||
|
await app.storage.get_user(user_id)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
@ -18,3 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .command import setup as migration
|
from .command import setup as migration
|
||||||
|
|
||||||
|
__all__ = ['migration']
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import base64
|
|
||||||
import itsdangerous
|
|
||||||
import bcrypt
|
|
||||||
from litecord.blueprints.auth import create_user, make_token
|
from litecord.blueprints.auth import create_user, make_token
|
||||||
from litecord.blueprints.users import delete_user
|
from litecord.blueprints.users import delete_user
|
||||||
from litecord.enums import UserFlags
|
from litecord.enums import UserFlags
|
||||||
|
|
|
||||||
6
run.py
6
run.py
|
|
@ -58,7 +58,7 @@ from litecord.blueprints.user.billing_job import payment_job
|
||||||
|
|
||||||
from litecord.blueprints.admin_api import (
|
from litecord.blueprints.admin_api import (
|
||||||
voice as voice_admin, features as features_admin,
|
voice as voice_admin, features as features_admin,
|
||||||
guilds as guilds_admin
|
guilds as guilds_admin, users as users_admin, instance_invites
|
||||||
)
|
)
|
||||||
|
|
||||||
from litecord.blueprints.admin_api.voice import guild_region_check
|
from litecord.blueprints.admin_api.voice import guild_region_check
|
||||||
|
|
@ -146,7 +146,9 @@ def set_blueprints(app_):
|
||||||
|
|
||||||
voice_admin: '/admin/voice',
|
voice_admin: '/admin/voice',
|
||||||
features_admin: '/admin/guilds',
|
features_admin: '/admin/guilds',
|
||||||
guilds_admin: '/admin/guilds'
|
guilds_admin: '/admin/guilds',
|
||||||
|
users_admin: '/admin/users',
|
||||||
|
instance_invites: '/admin/instance/invites'
|
||||||
}
|
}
|
||||||
|
|
||||||
for bp, suffix in bps.items():
|
for bp, suffix in bps.items():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue