ワンタイムパスワードの仕様変更に対応
This commit is contained in:
parent
33dd3aef9b
commit
aebab83b86
1 changed files with 45 additions and 16 deletions
|
@ -334,15 +334,29 @@ def register():
|
|||
with open(onetime_config_path, "r") as r:
|
||||
onetime_config = json.load(r)
|
||||
|
||||
if onetime_password == onetime_config["onetime"]["pc_register"]:
|
||||
if onetime_password == onetime_config["onetime"]["pc_register"]["password"]:
|
||||
register_result = auth.register(pc_number=pc_number, pc_uuid=pc_uuid)
|
||||
if register_result["result"] == 0:
|
||||
pc_token = register_result["output_dict"]["pc_token"]
|
||||
master_password = register_result["output_dict"]["master_password"]
|
||||
master_password_hash = register_result["output_dict"]["master_password_hash"]
|
||||
onetime_config["onetime"]["pc_register"] = None
|
||||
onetime_config["onetime"]["pc_register"]["current_count"] += 1
|
||||
|
||||
if onetime_config["onetime"]["pc_register"]["current_count"] == onetime_config["onetime"]["pc_register"]["max_count"]:
|
||||
onetime_config["onetime"]["pc_register"]["password"] = None
|
||||
with open(onetime_config_path, "w") as w:
|
||||
json.dump(onetime_config, w, indent=4)
|
||||
return jsonify({'message': 'ok', 'pc_token': pc_token, 'master_password': master_password, 'master_password_hash': master_password_hash}), 200
|
||||
else:
|
||||
with open(onetime_config_path, "w") as w:
|
||||
json.dump(onetime_config, w, indent=4)
|
||||
return jsonify({'message': 'ok', 'pc_token': pc_token, 'master_password': master_password, 'master_password_hash': master_password_hash}), 200
|
||||
elif register_result["result"] == 1:
|
||||
if register_result["about"] == "exist":
|
||||
return jsonify({'message': 'exist'}), 401
|
||||
else:
|
||||
return jsonify({'message': 'damedesu'}), 401
|
||||
|
||||
else:
|
||||
return jsonify({'message': 'damedesu'}), 401
|
||||
else:
|
||||
|
@ -410,22 +424,37 @@ def device_register():
|
|||
device_register = auth.device_register(mode="keyboard", number=number, device_instance_path=device_instance_path, device_name=device_name)
|
||||
if device_register["result"] == 0:
|
||||
print(f"キーボード {number} 番の登録処理は成功しました.")
|
||||
onetime_config["onetime"]["device_register"]["current_count"] += 1
|
||||
|
||||
if onetime_config["onetime"]["device_register"]["current_count"] == onetime_config["onetime"]["device_register"]["max_count"]:
|
||||
onetime_config["onetime"]["device_register"] = None
|
||||
with open(onetime_config_path, "w") as w:
|
||||
json.dump(onetime_config, w, indent=4)
|
||||
return jsonify({'message': 'ok'}), 200
|
||||
else:
|
||||
with open(onetime_config_path, "w") as w:
|
||||
json.dump(onetime_config, w, indent=4)
|
||||
return jsonify({'message': 'ok'}), 200
|
||||
else:
|
||||
print(f"キーボード {number} 番の登録処理は失敗しました.")
|
||||
return jsonify({'message': 'error'}), 500
|
||||
|
||||
elif mode == "mouse":
|
||||
print("マウスの登録処理を開始...")
|
||||
device_register = auth.device_register(mode="mouse", number=number, device_instance_path=device_instance_path, device_name=device_name)
|
||||
if device_register["result"] == 0:
|
||||
print(f"マウス {number} 番の登録処理は成功しました.")
|
||||
onetime_config["onetime"]["device_register"]["current_count"] += 1
|
||||
|
||||
if onetime_config["onetime"]["device_register"]["current_count"] == onetime_config["onetime"]["device_register"]["max_count"]:
|
||||
onetime_config["onetime"]["device_register"] = None
|
||||
with open(onetime_config_path, "w") as w:
|
||||
json.dump(onetime_config, w, indent=4)
|
||||
return jsonify({'message': 'ok'}), 200
|
||||
else:
|
||||
with open(onetime_config_path, "w") as w:
|
||||
json.dump(onetime_config, w, indent=4)
|
||||
return jsonify({'message': 'ok'}), 200
|
||||
else:
|
||||
print(f"マウス {number} 番の登録処理は失敗しました.")
|
||||
return jsonify({'message': 'error'}), 500
|
||||
|
|
Loading…
Reference in a new issue