Fixed order in which AUTH Token is generated

This commit is contained in:
ahmadbilalkhalid 2019-12-03 18:45:45 +05:00
parent 4c916072c3
commit 0ea2a68142

View file

@ -17,9 +17,6 @@ app = Flask(__name__)
api = Api(app)
# load configs
AUTH_NAME = config("AUTH_NAME", "")
AUTH_TOKEN = TOTP(config("AUTH_SEED", "")).now()
AUTH_REALM = config("AUTH_REALM", "")
OTP_SERVER = config("OTP_SERVER", "")
OTP_VERIFY_ENDPOINT = config("OTP_VERIFY_ENDPOINT", "verify/")
@ -33,9 +30,9 @@ except UndefinedValueError as uve:
def check_otp(name, realm, token):
try:
data = {
"auth_name": AUTH_NAME,
"auth_token": AUTH_TOKEN,
"auth_realm": AUTH_REALM,
"auth_name": config("AUTH_NAME", ""),
"auth_token": TOTP(config("AUTH_SEED", "")).now(),
"auth_realm": config("AUTH_REALM", ""),
"name": name,
"realm": realm,
"token": token,
@ -48,16 +45,18 @@ def check_otp(name, realm, token):
OTP_SERVER=OTP_SERVER,
OTP_VERIFY_ENDPOINT=OTP_VERIFY_ENDPOINT,
),
data=data,
json=data,
)
return response.status_code
def get_plan_id_from_product(product):
plan_id = "ucloud-v1-"
plan_id += product["name"].strip().replace(' ', '-') + "-"
plan_id += product["type"]
return plan_id
def get_order_id():
order_id_kv = client.get("/v1/last_order_id")
if order_id_kv is not None:
@ -67,6 +66,7 @@ def get_order_id():
client.put("/v1/last_order_id", str(order_id))
return "OR-{}".format(order_id)
def get_pricing(price_in_chf_cents, product_type, recurring_period):
if product_type == "recurring":
return "CHF {}/{}".format(
@ -76,6 +76,7 @@ def get_pricing(price_in_chf_cents, product_type, recurring_period):
elif product_type == "one-time":
return "CHF {} (One time charge)".format(price_in_chf_cents/100)
def get_user_friendly_product(product_dict):
uf_product = {
"name": product_dict["name"],
@ -91,7 +92,6 @@ def get_user_friendly_product(product_dict):
return uf_product
class ListProducts(Resource):
@staticmethod
def get():