예제 #1
0
def _self(who, user):
    if who != user["email"]:
        response.status = 400
    else:
        return whitelist(user, ["pseudonym",
                                "firstName",
                                "surname",
                                "email",
                                "private_email"])
예제 #2
0
def user_(who):
    try:
        return whitelist(c.db().users.find_one({"email": who}), [
                "email",
                "firstName",
                "pseudonym"
                ])
    except TypeError:
        logger.warn("Asked about {email}, but that is not a user".format(
            email=who))
        abort(404, "User not found")
예제 #3
0
def request_invite(who):
    # FIXME: Don't allow the pseudonym "public"
    user = whitelist(request.json, [
            "pseudonym",
            "firstName",
            "surname",
            "private_email",
            "token",
            ])
    if "private_email" not in user:
        abort(400, "You must provide a private_email field")
    user["email_key"] = str(uuid.uuid4())
    user["registered"] = c.unixtime()
    user["email"] = who
    c.db().users.ensure_index("email", unique=True)
    c.db().users.insert(user, safe=True)
    response.status = 202
    logger.info("{email} subscribed".format(email=who))
    jobs.enqueue(messages.SendInvite(user))