コード例 #1
0
def verify(verification_token):
    record = email_tokens_collection.find_one({'token': verification_token})
    if record is not None:
        update_dict = {'$set': {'account.email_verified': True}}
        helper_accounts_collection.update_one({'_id': record['helper_id']},
                                              update_dict)
        email_tokens_collection.delete_many({'helper_id': record['helper_id']})
コード例 #2
0
def modify_filter(params_dict):

    # params_dict["filter"] has already been validated

    helper_accounts_collection.update_one(
        {'email': params_dict["email"]},
        {'$set': {
            'filter': params_dict["filter"]
        }})

    return formatting.status("ok")
コード例 #3
0
def modify_forward(params_dict):

    # params_dict["forward"] has already been validated

    params_dict["forward"].update({'last_modified': timing.get_current_time()})

    helper_accounts_collection.update_one(
        {'email': params_dict["email"]},
        {'$set': {
            'forward': params_dict["forward"]
        }})

    return formatting.status("ok")
コード例 #4
0
ファイル: account_scripts.py プロジェクト: HelperLine/backend
def modify_account(params_dict):
    existing_document = helper_accounts_collection.find_one(
        {'email': params_dict["email"]})
    existing_account = existing_document["account"]
    new_account = params_dict["account"]

    update_dict = {}

    if 'new_email' in new_account:
        if (existing_document["email"] != new_account["new_email"]):
            if (existing_account['email_verified']):
                return formatting.status('email already verified')
            else:
                update_dict.update({"email": new_account["new_email"]})

    if 'old_password' in new_account and 'new_password' in new_account:
        if tokening.check_password(new_account['old_password'],
                                   existing_account['hashed_password']):
            update_dict.update({
                "account.hashed_password":
                tokening.hash_password(new_account['new_password'])
            })
        else:
            return formatting.status('old_password invalid')

    if 'zip_code' in new_account:
        update_dict.update({"account.zip_code": new_account['zip_code']})

    if 'country' in new_account:
        update_dict.update({"account.country": new_account['country']})

    if len(update_dict) != 0:
        helper_accounts_collection.update_one(
            {'email': existing_document["email"]}, {'$set': update_dict})

        if "email" in update_dict:
            # Send new verification email if new email valid
            email_tokens_collection.delete_many(
                {'email': existing_document["email"]})
            helper_api_keys_collection.update_one(
                {'email': existing_document["email"]},
                {'$set': {
                    'email': update_dict["email"]
                }})
            email_verification.trigger(update_dict["email"])

    return formatting.status("ok")
コード例 #5
0
def confirm(email):
    # this function can be used for the initial send as well as resending

    record = phone_tokens_collection.find_one({'email': email}, {
        '_id': 0,
        'phone_number': 1
    })

    if record is None:
        return formatting.status('not verification found'), 400

    if record['phone_number'] == '':
        return formatting.status('not verification found'), 400

    helper_accounts_collection.update_one({'email': email}, {
        '$set': {
            'phone_number': record['phone_number'],
            'phone_number_verified': True
        }
    })
    phone_tokens_collection.delete_many({'email': email})

    return formatting.status("ok"), 200