mapname -> namemap

pull/4/head
Blake DeMarcy 2017-03-03 00:15:13 -06:00
parent a4eb9f241a
commit a9634b9aea
2 changed files with 5 additions and 5 deletions

View File

@ -18,7 +18,7 @@ try:
USERDB = json.loads(f.read()) USERDB = json.loads(f.read())
except FileNotFoundError: except FileNotFoundError:
USERDB = dict(mapname=dict()) USERDB = dict(namemap=dict())
with open(path.join(PATH, "userdb"), "w") as f: with open(path.join(PATH, "userdb"), "w") as f:
f.write(json.dumps(USERDB)) f.write(json.dumps(USERDB))
path.os.chmod(path.join(PATH, "userdb"), 0o600) path.os.chmod(path.join(PATH, "userdb"), 0o600)
@ -95,19 +95,19 @@ def user_resolve(name_or_id):
if check: if check:
return name_or_id return name_or_id
else: else:
return USERDB["mapname"][name_or_id] return USERDB["namemap"][name_or_id]
except KeyError: except KeyError:
return False return False
def user_register(auth_hash, name, quip, bio): def user_register(auth_hash, name, quip, bio):
if USERDB["mapname"].get(name): if USERDB["namemap"].get(name):
return schema.error(4, "Username taken.") return schema.error(4, "Username taken.")
ID = uuid1().hex ID = uuid1().hex
scheme = schema.user_internal(ID, auth_hash, name, quip, bio, False) scheme = schema.user_internal(ID, auth_hash, name, quip, bio, False)
USERDB.update({ID: scheme}) USERDB.update({ID: scheme})
USERDB["mapname"].update({name: ID}) USERDB["namemap"].update({name: ID})
user_dbdump(USERDB) user_dbdump(USERDB)
return scheme return scheme

View File

@ -32,7 +32,7 @@ def create_usermap(thread, index=False):
def is_registered(json): def is_registered(json):
return bool(db.USERDB["mapname"].get(json["target_user"])) return bool(db.USERDB["namemap"].get(json["target_user"]))
def check_auth(json): def check_auth(json):