Beispiel #1
0
def get_user_by_attr(attr_dic):
    coll = User.collection()
    dic = coll.find_one(attr_dic)

    # found sth
    user_obj = User.unserialize(dic) if dic is not None else None
    return user_obj
Beispiel #2
0
def confirm(user_obj):
    """
    Updates a newly registered user account from a AWAITING_CONFIRMATION status
    to an ENABLED status.

    :param user_obj:
    :return:
    """
    coll = User.collection()
    user_obj.account_status = AccountStatus.ENABLED
    coll.update({"_id": user_obj.obj_id()}, user_obj.serialize(), upsert=False)
Beispiel #3
0
def remove_token(user_obj, account_activity):
    """
    Removes a token for a specific account activity.
    (EG: When a user has a verified his/her new account)

    Does nothing if there does not exists a token for
    the activity.
    """
    if account_activity in user_obj.tokens:
        del user_obj.tokens[account_activity]
        coll = User.collection()
        coll.update({"_id": user_obj._id}, user_obj.serialize(), upsert=False)
Beispiel #4
0
def get(user_id):
    coll = User.collection()
    dic = coll.find_one({"_id": user_id})
    user_obj = User.unserialize(dic) if dic is not None else None
    return user_obj