def do_login(password): user = users.find_by_password(password) if user: session['user_id'] = user.id session.permanent = True return True if user else False
def test_get_or_gen_password(): f1 = {"password": "******"} p1 = users.get_or_gen_password(f1) assert p1 == "1234" f2 = {"password": ""} p2 = users.get_or_gen_password(f2) assert not users.find_by_password(p2)
def do_mobile_login(password): user = users.find_by_password(password) if user: sid = users.issue_new_session_id(user.id) return (user.id, sid) if user else (None, None)