コード例 #1
0
ファイル: redirect.py プロジェクト: renzon/pswdless
def index(_handler, _resp, lang, signed_ticket_id):
    languages.setup_locale(lang)
    cmd = facade.validate_login_link(signed_ticket_id, _handler.redirect)
    try:
        cmd.execute()
    except CommandExecutionException:
        _resp.status_code = 400
        values = {'errors': cmd.errors, 'site': None}
        if cmd.result:
            search = DestinationsSearch(LoginSite, cmd.result)
            search.execute()
            if search.result:
                values['site'] = search.result[0]
        return TemplateResponse(values, "login_error.html")
コード例 #2
0
ファイル: login_tests.py プロジェクト: renzon/pswdless
    def test_success(self, hook='https://pswdless.appspot.com/foo', expected_query_string='?ticket=%s'):
        lg = Login(status=LOGIN_EMAIL, hook=hook)
        lg.put()

        cmd = cookie_facade.sign('ticket', lg.key.id())
        cmd.execute()
        redirect_mock = Mock()
        validate_cmd = facade.validate_login_link(cmd.result, redirect_mock)
        validate_cmd.execute()
        self.assertDictEqual({}, validate_cmd.errors)
        login_db = validate_cmd.result
        self.assertEqual(lg.key, login_db.key)
        self.assertEqual(login_db.status, LOGIN_CLICK)
        search = LoginStatusArcSearch(login_db)
        search.execute()
        self.assertEqual(1, len(search.result))
        lg_status = search.result[0]
        self.assertIsInstance(lg_status, LoginStatus)
        self.assertEqual(lg_status.label, LOGIN_CLICK)
        redirect_mock.assert_called_once_with(hook + (expected_query_string % lg.key.id()))
コード例 #3
0
ファイル: login_tests.py プロジェクト: renzon/pswdless
    def test_success(self,
                     hook='https://pswdless.appspot.com/foo',
                     expected_query_string='?ticket=%s'):
        lg = Login(status=LOGIN_EMAIL, hook=hook)
        lg.put()

        cmd = cookie_facade.sign('ticket', lg.key.id())
        cmd.execute()
        redirect_mock = Mock()
        validate_cmd = facade.validate_login_link(cmd.result, redirect_mock)
        validate_cmd.execute()
        self.assertDictEqual({}, validate_cmd.errors)
        login_db = validate_cmd.result
        self.assertEqual(lg.key, login_db.key)
        self.assertEqual(login_db.status, LOGIN_CLICK)
        search = LoginStatusArcSearch(login_db)
        search.execute()
        self.assertEqual(1, len(search.result))
        lg_status = search.result[0]
        self.assertIsInstance(lg_status, LoginStatus)
        self.assertEqual(lg_status.label, LOGIN_CLICK)
        redirect_mock.assert_called_once_with(hook + (expected_query_string %
                                                      lg.key.id()))