archive
/
yubi-lock
Archived
1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
yubi-lock/yubi_lock/api/user.py

24 lines
554 B
Python

import os, pwd, json
from yubi_lock.api import BASE_DIR
def get_username():
return pwd.getpwuid(os.getuid())[0]
def store_key(ident):
with open(os.path.join(BASE_DIR, "data/keys.json")) as file:
existing_data = json.load(file)
existing_data.append(ident)
with open(os.path.join(BASE_DIR, "data/keys.json"), 'w') as file:
json.dump(existing_data, file)
def has_ident(ident):
with open(os.path.join(BASE_DIR, "data/keys.json")) as file:
existing_data = json.load(file)
return ident in existing_data