Beispiel #1
0
def login():
    username = request.args.get("username", None)
    if not username:
        return jsonify(ok=False, error="Missing the `username` parameter")

    password = request.args.get("password", None)
    if not password:
        return jsonify(ok=False, error="Missing the `password` parameter")

    user_doc = db.user_from_username(username)
    if not user_doc or hash_password(password) != user_doc["password"]:
        return jsonify(ok=False, error="Unknown username or wrong password")

    return jsonify(ok=True, user_oid=str(user_doc["_id"]))
Beispiel #2
0
import db

db.users_coll.drop()

db.create_user("dan", "none_yet")
db.create_user("sean", "none_yet")

print "Dan: %s" % (str(db.user_from_username("dan")["_id"]),)
print "Sean: %s" % (str(db.user_from_username("sean")["_id"]),)
Beispiel #3
0
 def from_username(username):
     return User.from_doc(db.user_from_username(username))