mirror of https://gitlab.com/litecord/litecord.git
blueprints.auth: add *dummy* POST /api/v6/auth/register_inv
- litecord.schemas: add REGISTER, REGISTER_WITH_INVITE - run: add GET /register - add static/invite_register.html
This commit is contained in:
parent
b17d166377
commit
e949dbdc3f
|
|
@ -5,6 +5,7 @@ import bcrypt
|
|||
from quart import Blueprint, jsonify, request, current_app as app
|
||||
|
||||
from litecord.auth import token_check, create_user
|
||||
from litecord.schemas import validate, REGISTER, REGISTER_WITH_INVITE
|
||||
|
||||
|
||||
bp = Blueprint('auth', __name__)
|
||||
|
|
@ -47,6 +48,19 @@ async def register():
|
|||
})
|
||||
|
||||
|
||||
@bp.route('/register_inv', methods=['POST'])
|
||||
async def _register_with_invite():
|
||||
data = await request.form
|
||||
|
||||
# dummy for now
|
||||
print(data['username'])
|
||||
print(data['email'])
|
||||
print(data['password'])
|
||||
print(data['invcode'])
|
||||
|
||||
return 'dab', 200
|
||||
|
||||
|
||||
@bp.route('/login', methods=['POST'])
|
||||
async def login():
|
||||
j = await request.get_json()
|
||||
|
|
|
|||
|
|
@ -150,6 +150,16 @@ def validate(reqjson: Union[Dict, List], schema: Dict,
|
|||
return validator.document
|
||||
|
||||
|
||||
REGISTER = {
|
||||
'email': {'type': 'email'},
|
||||
'username': {'type': 'username'},
|
||||
'password': {'type': 'string', 'minlength': 5}
|
||||
}
|
||||
|
||||
REGISTER_WITH_INVITE = {**REGISTER, **{
|
||||
'invcode': {'type': 'string', 'required': True}
|
||||
}
|
||||
|
||||
USER_UPDATE = {
|
||||
'username': {
|
||||
'type': 'username', 'minlength': 2,
|
||||
|
|
|
|||
8
run.py
8
run.py
|
|
@ -5,7 +5,7 @@ import asyncpg
|
|||
import logbook
|
||||
import logging
|
||||
import websockets
|
||||
from quart import Quart, g, jsonify, request
|
||||
from quart import Quart, g, jsonify, request, send_file
|
||||
from logbook import StreamHandler, Logger
|
||||
from logbook.compat import redirect_logging
|
||||
|
||||
|
|
@ -285,3 +285,9 @@ async def handle_500(err):
|
|||
async def index():
|
||||
"""sample index page."""
|
||||
return 'hewwo'
|
||||
|
||||
|
||||
@app.route('/register')
|
||||
async def register_frontend():
|
||||
"""basic register page."""
|
||||
return await send_file('static/invite_register.html')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>register</p>
|
||||
|
||||
<form method="post" action="/api/v6/auth/register_inv">
|
||||
<p>your username</p>
|
||||
<input type="text" name="username"/>
|
||||
<p>your email</p>
|
||||
<input type="text" name="email"/>
|
||||
<p>your password</p>
|
||||
<input type="password" name="password"/>
|
||||
<p>invite code</p>
|
||||
<input type="text" name="invcode"/>
|
||||
|
||||
<p/><input type="submit" value="register">
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue