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
1 changed files with 8 additions and 8 deletions

View File

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