コード例 #1
0
ファイル: app.py プロジェクト: srobo-legacy/nemesis
def send_password_reset(requesting_user, userid):
    user_to_update = User.create_user(userid)
    if not requesting_user.can_administrate(user_to_update):
        return AUTHORIZATION_DENIED

    verify_code = helpers.create_verify_code(user_to_update.username,
                                             requesting_user.username)

    ppr = PendingPasswordReset(user_to_update.username)
    ppr.requestor_username = requesting_user.username
    ppr.verify_code = verify_code
    ppr.save()

    log_action('sending password reset', ppr)

    url = url_for('reset_password',
                  username=user_to_update.username,
                  code=verify_code,
                  _external=True)
    ppr.send_reset_email(
        user_to_update.email,
        user_to_update.first_name,
        url,
        "{0} {1}".format(requesting_user.first_name,
                         requesting_user.last_name),
    )

    return "{}", 202
コード例 #2
0
def test_properties():
    ppr = PendingPasswordReset('abc')
    ppr.requestor_username = '******'
    ppr.verify_code = 'bibble'

    assert ppr.username == 'abc'
    assert ppr.requestor_username == 'dave'
    assert ppr.verify_code == 'bibble'
コード例 #3
0
def test_properties():
    ppr = PendingPasswordReset('abc')
    ppr.requestor_username = '******'
    ppr.verify_code = 'bibble'

    assert ppr.username == 'abc'
    assert ppr.requestor_username == 'dave'
    assert ppr.verify_code == 'bibble'
コード例 #4
0
ファイル: helpers_tests.py プロジェクト: PeterJCLaw/nemesis
    def test_clear_old_password_resets(self):
        ppr = PendingPasswordReset('old')
        ppr.requestor_username = '******'
        ppr.verify_code = 'bibble-old'
        ppr.save()

        self._make_old('password_resets', 'old')

        ppr = PendingPasswordReset('abc')
        ppr.requestor_username = '******'
        ppr.verify_code = 'bibble-new'
        ppr.save()

        helpers.clear_old_password_resets()

        ppr = PendingPasswordReset('old')
        assert not ppr.in_db

        ppr = PendingPasswordReset('abc')
        assert ppr.in_db
コード例 #5
0
ファイル: helpers_tests.py プロジェクト: PeterJCLaw/nemesis
    def test_clear_old_password_resets(self):
        ppr = PendingPasswordReset('old')
        ppr.requestor_username = '******'
        ppr.verify_code = 'bibble-old'
        ppr.save()

        self._make_old('password_resets', 'old')

        ppr = PendingPasswordReset('abc')
        ppr.requestor_username = '******'
        ppr.verify_code = 'bibble-new'
        ppr.save()

        helpers.clear_old_password_resets()

        ppr = PendingPasswordReset('old')
        assert not ppr.in_db

        ppr = PendingPasswordReset('abc')
        assert ppr.in_db
コード例 #6
0
def test_creation():
    ppr = PendingPasswordReset('abc')
    ppr.requestor_username = '******'
    ppr.verify_code = 'bibble'

    ppr.save()
    assert ppr.in_db

    ppr = PendingPasswordReset('abc')
    assert ppr.in_db
    assert ppr.username == 'abc'
    assert ppr.requestor_username == 'dave'
    assert ppr.verify_code == 'bibble'
    age = ppr.age
    assert age > timedelta()
    assert age < timedelta(minutes=1)
コード例 #7
0
def test_creation():
    ppr = PendingPasswordReset('abc')
    ppr.requestor_username = '******'
    ppr.verify_code = 'bibble'

    ppr.save()
    assert ppr.in_db

    ppr = PendingPasswordReset('abc')
    assert ppr.in_db
    assert ppr.username == 'abc'
    assert ppr.requestor_username == 'dave'
    assert ppr.verify_code == 'bibble'
    age = ppr.age
    assert age > timedelta()
    assert age < timedelta(minutes = 1)
コード例 #8
0
ファイル: app.py プロジェクト: PeterJCLaw/nemesis
def send_password_reset(requesting_user, userid):
    user_to_update = User.create_user(userid)
    if not requesting_user.can_administrate(user_to_update):
        return AUTHORIZATION_DENIED

    verify_code = helpers.create_verify_code(user_to_update.username, requesting_user.username)

    ppr = PendingPasswordReset(user_to_update.username)
    ppr.requestor_username = requesting_user.username
    ppr.verify_code = verify_code
    ppr.save()

    log_action('sending password reset', ppr)

    url = url_for('reset_password', username=user_to_update.username, code=verify_code, _external=True)
    ppr.send_reset_email(
        user_to_update.email,
        user_to_update.first_name,
        url,
        "{0} {1}".format(requesting_user.first_name, requesting_user.last_name),
    )

    return "{}", 202
コード例 #9
0
def setup_password_reset(for_user, verify_code):
    ppr = PendingPasswordReset(for_user)
    ppr.requestor_username = '******'
    ppr.verify_code = verify_code
    ppr.save()
コード例 #10
0
def setup_password_reset(for_user, verify_code):
    ppr = PendingPasswordReset(for_user)
    ppr.requestor_username = '******'
    ppr.verify_code = verify_code
    ppr.save()