def register(cls, email, passwd, name, birth, gender): passwd = hashlib.md5(passwd).hexdigest() authkey = hashlib.sha256(email + "+" + passwd).hexdigest() ENTITY_DB.insert( {"email": email, "passwd": passwd, "authkey": authkey, "name": name, "gender": gender, "birth": birth}, tb="user", ) return ENTITY_DB.get_id({"email": email}, tb="user"), authkey
def login(cls, email, passwd): passwd = hashlib.md5(passwd).hexdigest() return ENTITY_DB.select_dict(["id", "authkey", "name"], {"email": email, "passwd": passwd}, tb="user")
def check_email_valid(cls, email): if ENTITY_DB.get_id(where={"email": email}, tb="user") == 0: return True else: return False
def authenticate(cls, authkey): return ENTITY_DB.select_dict(["id", "name"], {"authkey": authkey}, tb="user")
def write_timeline(cls, user_id, content, lat, lng, img_id=0, visiblity=0): meta = cls.build_meta(visiblity) ENTITY_DB.insert({"user_id": user_id, "content": content, "lat": lat, "lng": lng, "img_id": img_id, "meta": meta}, tb="timeline")