account bar
This commit is contained in:
@@ -12,6 +12,7 @@ from flask_jwt_extended import (
|
||||
get_jwt_identity,
|
||||
)
|
||||
from app.config import Config
|
||||
from datetime import timedelta
|
||||
|
||||
USERNAME = Config.BASIC_AUTH_USERNAME
|
||||
PASSWORD = Config.BASIC_AUTH_PASSWORD
|
||||
@@ -46,7 +47,8 @@ class AuthorizationService(BaseService):
|
||||
):
|
||||
return ResponseHelper.unauthorized(result_description="Invalid credentials")
|
||||
|
||||
access_token = create_access_token(identity=validated_data["username"])
|
||||
expires = timedelta(days=3)
|
||||
access_token = create_access_token(identity=validated_data["username"], expires_delta=expires)
|
||||
refresh_token = create_refresh_token(identity=validated_data["username"])
|
||||
|
||||
# Simulated processing logic
|
||||
|
||||
@@ -13,6 +13,7 @@ from app.api.helpers.response_helper import ResponseHelper
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
from app.api.schemas.register import RegisterSchema
|
||||
from app.api.schemas.products import ProductsSchema
|
||||
from app.api.schemas.user import UserSchema
|
||||
|
||||
import datetime
|
||||
import jwt
|
||||
@@ -35,25 +36,29 @@ class ProductsService(BaseService):
|
||||
"""
|
||||
try:
|
||||
|
||||
user_id = 1 # current_user["user"]["id"]
|
||||
PRODUCT_LIST = f"""SELECT p.id,p.uid,p.product_id,p.name,p.description,p.status,p.banner,
|
||||
mp.status AS prov_status,
|
||||
(CASE WHEN mp.status =6 THEN 'Preparing' WHEN mp.status=7 THEN 'Active' ELSE 'Activate Now' END) AS status_text
|
||||
FROM products p
|
||||
LEFT JOIN members_products mp ON mp.product_id = p.product_id
|
||||
AND mp.member_id ={user_id}
|
||||
ORDER BY p.id ASC"""
|
||||
print(PRODUCT_LIST)
|
||||
|
||||
|
||||
with db.session.begin():
|
||||
|
||||
validated_data = ProductsService.validate_data(data, ProductsSchema())
|
||||
# username = validated_data.get('username')
|
||||
# password = validated_data.get('password')
|
||||
validated_data = ProductsService.validate_data(data, UserSchema())
|
||||
token = validated_data.get('token')
|
||||
uid = validated_data.get('uid')
|
||||
|
||||
user_id = 1 # current_user["user"]["id"]
|
||||
PRODUCT_LIST = f"""SELECT p.id,p.uid,p.product_id,p.name,p.description,p.status,p.banner,
|
||||
mp.status AS prov_status,
|
||||
(CASE WHEN mp.status =6 THEN 'Preparing' WHEN mp.status=7 THEN 'Active' ELSE 'Activate Now' END) AS status_text
|
||||
FROM products p
|
||||
LEFT JOIN members_products mp ON mp.product_id = p.product_id
|
||||
AND mp.member_id ={user_id}
|
||||
ORDER BY p.id ASC"""
|
||||
print(PRODUCT_LIST)
|
||||
|
||||
data = db.engine.execute(PRODUCT_LIST)
|
||||
|
||||
# Simulate processing
|
||||
response_data = {
|
||||
"data": data.fetchall(),
|
||||
"member_id": 0,
|
||||
"uid": 0,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user