def login(): username = request.values.get("username") password = request.values.get("password") uid = User.login_challenge(username, password) if uid is None: session.pop("user_id", None) return jsonify({"error": 1002, "error_msg": "failed"}) else: session["user_id"] = uid return jsonify({"error": 0})
def test_login_challenge(self): uid = User.create("jack", "password") assert uid is not None assert uid == User.login_challenge("jack", "password") assert None is User.login_challenge("jack2", "password") assert None is User.login_challenge("jack2", "password2")