當前位置: 首頁>>代碼示例>>Python>>正文


Python views.ForgotPasswordController類代碼示例

本文整理匯總了Python中horus.views.ForgotPasswordController的典型用法代碼示例。如果您正苦於以下問題:Python ForgotPasswordController類的具體用法?Python ForgotPasswordController怎麽用?Python ForgotPasswordController使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ForgotPasswordController類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_forgot_password_invalid_password

    def test_forgot_password_invalid_password(self):
        from horus.views import ForgotPasswordController
        from pyramid_mailer.interfaces import IMailer
        from pyramid_mailer.mailer import DummyMailer
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User

        self.config.registry.registerUtility(User, IUserClass)

        self.config.add_route('index', '/')
        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        user = User(username='sontek', password='temp',
            email='[email protected]')
        user.password = 'foo'

        self.session.add(user)
        self.session.flush()

        request = self.get_csrf_request(post={
            'email': 'sontek'
        }, request_method='POST')

        request.user = None

        view = ForgotPasswordController(request)
        response = view.forgot_password()

        assert len(response['errors']) == 1
開發者ID:dobrite,項目名稱:horus,代碼行數:30,代碼來源:test_views.py

示例2: test_forgot_password_valid_user

    def test_forgot_password_valid_user(self):
        from horus.views import ForgotPasswordController
        from pyramid_mailer.interfaces import IMailer
        from pyramid_mailer.mailer import DummyMailer
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User

        self.config.registry.registerUtility(User, IUserClass)

        self.config.add_route('index', '/')
        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        user = User(username='sontek', password='temp', email='[email protected]')
        user.password = 'foo'

        self.session.add(user)
        self.session.flush()

        request = self.get_csrf_request(post={
            'email': '[email protected]'
        }, request_method='POST')

        request.user = None

        flash = Mock()
        request.session.flash = flash

        view = ForgotPasswordController(request)
        response = view.forgot_password()

        flash.assert_called_with(
            'Please check your e-mail to reset your password.', 'success')
        assert response.status_int == 302
開發者ID:pzatrick,項目名稱:horus,代碼行數:34,代碼來源:test_views.py

示例3: test_forgot_password_valid_user

    def test_forgot_password_valid_user(self):
        from horus.views                import ForgotPasswordController
        from pyramid_mailer.interfaces  import IMailer
        from pyramid_mailer.mailer      import DummyMailer
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User
        self.config.registry.registerUtility(User, IUserClass)

        self.config.add_route('index', '/')
        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        user = User(username='sontek', password='temp',
            email='[email protected]')
        user.password = 'foo'

        self.session.add(user)
        self.session.flush()

        request = self.get_csrf_request(post={
            'email': '[email protected]'
        }, request_method='POST')

        request.user = None

        view = ForgotPasswordController(request)

        with patch('horus.views.FlashMessage') as FlashMessage:
            response = view.forgot_password()
            FlashMessage.assert_called_with(request,
                view.Str.reset_password_email_sent, kind="success")
        assert response.status_int == 302
開發者ID:dobrite,項目名稱:horus,代碼行數:32,代碼來源:test_views.py

示例4: test_reset_password_valid_user

    def test_reset_password_valid_user(self):
        from horus.views import ForgotPasswordController
        from hem.interfaces import IDBSession
        from horus.events import PasswordResetEvent
        from pyramid_mailer.interfaces import IMailer
        from pyramid_mailer.mailer import DummyMailer
        from horus.models import crypt
        from horus.interfaces           import IHorusUserClass
        from horus.interfaces           import IHorusActivationClass
        from horus.tests.models         import User
        from horus.tests.models         import Activation

        self.config.registry.registerUtility(User, IHorusUserClass)
        self.config.registry.registerUtility(Activation, IHorusActivationClass)


        self.config.add_route('index', '/')
        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        user = User(username='sontek', email='[email protected]')
        user.set_password('foo')
        user.activation = Activation()

        self.session.add(user)
        self.session.flush()

        request = self.get_csrf_request(post={
            'Password': {
                'Password': 'test123',
                'Password-confirm': 'test123',
            },
        }, request_method='POST')

        request.matchdict = Mock()
        get = Mock()
        get.return_value = user.activation.code
        request.matchdict.get = get

        request.user = None

        flash = Mock()
        request.session.flash = flash

        def handle_password_reset(event):
            request = event.request
            session = request.registry.getUtility(IDBSession)
            session.commit()

        self.config.add_subscriber(handle_password_reset, PasswordResetEvent)

        view = ForgotPasswordController(request)
        response = view.reset_password()

        assert not crypt.check(user.password, 'temp' + user.salt)
        assert response.status_int == 302
開發者ID:zerotired,項目名稱:horus,代碼行數:56,代碼來源:test_views.py

示例5: test_forgot_password_logged_in_redirects

    def test_forgot_password_logged_in_redirects(self):
        from horus.views import ForgotPasswordController
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User

        self.config.registry.registerUtility(User, IUserClass)
        self.config.add_route('index', '/')
        self.config.include('horus')

        request = testing.DummyRequest()
        request.user = Mock()
        view = ForgotPasswordController(request)
        response = view.forgot_password()

        assert response.status_int == 302
開發者ID:dobrite,項目名稱:horus,代碼行數:15,代碼來源:test_views.py

示例6: test_reset_password_invalid_password

    def test_reset_password_invalid_password(self):
        from horus.views import ForgotPasswordController
        from pyramid_mailer.interfaces import IMailer
        from pyramid_mailer.mailer import DummyMailer
        from horus.interfaces           import IUserClass
        from horus.interfaces           import IActivationClass
        from horus.tests.models         import User
        from horus.tests.models         import Activation

        self.config.registry.registerUtility(User, IUserClass)
        self.config.registry.registerUtility(Activation, IActivationClass)

        self.config.add_route('index', '/')
        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)


        user = User(username='sontek', password='temp', email='[email protected]')
        user.password = 'foo'
        user.activation = Activation()

        self.session.add(user)
        self.session.flush()

        request = self.get_csrf_request(post={
            'Password': {
                'Password': 't',
                'Password-confirm': 't',
            },
        }, request_method='POST')

        request.matchdict = Mock()
        get = Mock()
        get.return_value = user.activation.code
        request.matchdict.get = get

        request.user = None

        flash = Mock()
        request.session.flash = flash

        view = ForgotPasswordController(request)
        response = view.reset_password()

        assert len(response['errors']) == 1
開發者ID:pzatrick,項目名稱:horus,代碼行數:45,代碼來源:test_views.py

示例7: test_forgot_password_loads

    def test_forgot_password_loads(self):
        from horus.views import ForgotPasswordController
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User
        from horus.interfaces           import IActivationClass
        from horus.tests.models         import Activation
        self.config.registry.registerUtility(Activation, IActivationClass)

        self.config.registry.registerUtility(User, IUserClass)
        self.config.add_route('index', '/')
        self.config.include('horus')

        request = testing.DummyRequest()
        request.user = None
        view = ForgotPasswordController(request)
        response = view.forgot_password()

        assert response.get('form', None)
開發者ID:dobrite,項目名稱:horus,代碼行數:18,代碼來源:test_views.py

示例8: test_reset_password_loads

    def test_reset_password_loads(self):
        from horus.views import ForgotPasswordController
        from pyramid_mailer.interfaces import IMailer
        from pyramid_mailer.mailer import DummyMailer
        from horus.interfaces           import IUserClass
        from horus.tests.models         import User
        from horus.tests.models         import Activation
        from horus.interfaces           import IActivationClass

        self.config.registry.registerUtility(User, IUserClass)
        self.config.registry.registerUtility(Activation, IActivationClass)

        self.config.add_route('index', '/')
        self.config.include('horus')
        self.config.registry.registerUtility(DummyMailer(), IMailer)

        user = User(username='sontek', password='temp',
            email='[email protected]')
        user.password = 'foo'
        user.activation = Activation()

        self.session.add(user)
        self.session.flush()

        request = testing.DummyRequest()

        request.matchdict = Mock()
        get = Mock()
        get.return_value = user.activation.code
        request.matchdict.get = get

        request.user = None

        view = ForgotPasswordController(request)
        response = view.reset_password()

        assert response.get('form', None)
        assert 'sontek' in response['form']
開發者ID:dobrite,項目名稱:horus,代碼行數:38,代碼來源:test_views.py

示例9: forgot

    def forgot(self):
        request = self.request
        controller = ForgotPasswordController(request)
        form = self.forgot_form

        result = controller.forgot_password()
        if isinstance(result, dict):
            if 'errors' in result:
                error = colander.Invalid(
                    form.schema,
                    messages.INVALID_FORM
                )
                error.children = result.pop('errors')
                form.widget.handle_error(form, error)
            result = {
                'form': {
                    'forgot': form.render()
                }
            }
        else:
            # TODO: take care of flash success message
            return None
        return result
開發者ID:3divs,項目名稱:h,代碼行數:23,代碼來源:app.py


注:本文中的horus.views.ForgotPasswordController類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。