feat: initialize full-stack architecture with backend routes, database schema, and glassmorphic frontend UI
This commit is contained in:
@@ -11,6 +11,26 @@ auth_blueprint = Blueprint('auth', __name__)
|
||||
|
||||
@auth_blueprint.route('/auth/register', methods=['POST'])
|
||||
def register():
|
||||
"""
|
||||
Регистрация нового пользователя
|
||||
---
|
||||
tags:
|
||||
- Auth
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
username:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
responses:
|
||||
201:
|
||||
description: Пользователь успешно зарегистрирован
|
||||
"""
|
||||
data = request.json
|
||||
username = data.get('username')
|
||||
password = data.get('password')
|
||||
@@ -41,6 +61,30 @@ def register():
|
||||
|
||||
@auth_blueprint.route('/auth/login', methods=['POST'])
|
||||
def login():
|
||||
"""
|
||||
Вход в систему
|
||||
---
|
||||
tags:
|
||||
- Auth
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
username:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: Токен успешно сгенерирован
|
||||
schema:
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
"""
|
||||
data = request.json
|
||||
username = data.get('username')
|
||||
password = data.get('password')
|
||||
@@ -59,6 +103,11 @@ def login():
|
||||
'exp': datetime.utcnow() + timedelta(days=7)
|
||||
}, SECRET_KEY, algorithm="HS256")
|
||||
|
||||
# --- AUDIT LOG ---
|
||||
from ..utils.audit_utils import log_action
|
||||
log_action(user[0], 'LOGIN', {'ip': request.remote_addr})
|
||||
# -----------------
|
||||
|
||||
return jsonify({"token": token})
|
||||
|
||||
@auth_blueprint.route('/auth/me', methods=['GET'])
|
||||
|
||||
Reference in New Issue
Block a user