28 lines
829 B
Python
28 lines
829 B
Python
"""Public, visitor-bound customer login endpoints. No staff privileges."""
|
|
|
|
from flask import Blueprint, current_app, request
|
|
from werkzeug.exceptions import RequestEntityTooLarge
|
|
from .. import customer_service
|
|
|
|
bp = Blueprint('customer', __name__)
|
|
|
|
|
|
@bp.get('/api/customer/session')
|
|
def session():
|
|
return customer_service.session_status()
|
|
|
|
|
|
@bp.post('/api/customer/login')
|
|
def login():
|
|
request.max_content_length = 2048
|
|
try:
|
|
return customer_service.login(request.get_json(silent=True), current_app.extensions['customer_login_attempts'],
|
|
current_app.extensions['customer_login_lock'])
|
|
except RequestEntityTooLarge:
|
|
return {'ok':False,'error':'登录信息过长。'}, 413
|
|
|
|
|
|
@bp.post('/api/customer/logout')
|
|
def logout():
|
|
return customer_service.logout()
|