Re: [pgAdmin4][RM2892] Handle password changes properly if erroroccurs during sending email - Mailing list pgadmin-hackers

From Harshal Dhumal
Subject Re: [pgAdmin4][RM2892] Handle password changes properly if erroroccurs during sending email
Date
Msg-id CAFiP3vwLPPfNzYpTZggZzTGQYMBWeOHpB-G2cdB-d7d0RP4-uw@mail.gmail.com
Whole thread Raw
In response to Re: [pgAdmin4][RM2892] Handle password changes properly if erroroccurs during sending email  (Harshal Dhumal <harshal.dhumal@enterprisedb.com>)
Responses Re: [pgAdmin4][RM2892] Handle password changes properly if erroroccurs during sending email
List pgadmin-hackers
Hi Dave,

Please find patch to fix testsuite.

Changes:
1. Set config parameters SECURITY_RECOVERABLE and SECURITY_CHANGEABLE to True if SERVER_MODE is True
while running testsuite (Though we have set these parameters to True in create_app function but regression testsuite
initialises (imports) browser module before the app instance is created.)

2. Updated new URL references in testsuite code.

3. Also I have changed URL /browser/forgot_password to /browser/reset_password to make it consistent
with flask-security URL (as there is no such URL /forgot in flask-security)


-- 
Harshal Dhumal
Sr. Software Engineer

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Thu, Nov 30, 2017 at 5:09 PM, Harshal Dhumal <harshal.dhumal@enterprisedb.com> wrote:
sure Dave, looking in it now.

-- 
Harshal Dhumal
Sr. Software Engineer

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Thu, Nov 30, 2017 at 5:01 PM, Dave Page <dpage@pgadmin.org> wrote:
Oh, nuts - turns out this breaks the regression tests (the Python API tests) if they're run with SERVER_MODE = True. Can you take a look ASAP please?

Traceback (most recent call last):
  File "regression/runtests.py", line 325, in <module>
    test_utils.login_tester_account(test_client)
  File "/Users/dpage/git/pgadmin4/web/regression/python_test_utils/test_utils.py", line 53, in login_tester_account
    follow_redirects=True)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/test.py", line 772, in post
    return self.open(*args, **kw)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/testing.py", line 113, in open
    follow_redirects=follow_redirects)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/test.py", line 751, in open
    environ, buffered=buffered)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/test.py", line 691, in resolve_redirect
    buffered=buffered)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/testing.py", line 113, in open
    follow_redirects=follow_redirects)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/test.py", line 736, in open
    response = self.run_wsgi_app(environ, buffered=buffered)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/test.py", line 659, in run_wsgi_app
    rv = run_wsgi_app(self.application, environ, buffered=buffered)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/test.py", line 855, in run_wsgi_app
    app_iter = app(environ, start_response)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 2000, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1991, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1567, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask_login.py", line 792, in decorated_view
    return func(*args, **kwargs)
  File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/__init__.py", line 527, in index
    _=gettext
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/templating.py", line 134, in render_template
    context, ctx.app)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/templating.py", line 116, in _render
    rv = template.render(context)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
    return self.environment.handle_exception(exc_info, True)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/templates/browser/index.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/Users/dpage/git/pgadmin4/web/pgadmin/templates/base.html", line 66, in top-level template code
    {% block body %}{% endblock %}
  File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/templates/browser/index.html", line 175, in block "body"
    '{{ url_for('browser.change_password') }}'
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/helpers.py", line 332, in url_for
    return appctx.app.handle_url_build_error(error, endpoint, values)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1811, in handle_url_build_error
    reraise(exc_type, exc_value, tb)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/helpers.py", line 322, in url_for
    force_external=external)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/routing.py", line 1616, in build
    raise BuildError(endpoint, values, method)
werkzeug.routing.BuildError: ('browser.change_password', {}, None)
make: *** [check-python] Error 1

On Thu, Nov 30, 2017 at 11:17 AM, Dave Page <dpage@pgadmin.org> wrote:
Thanks - applied with minor changes to localise the messages and make it clear to the user that their password wasn't changed if there was an error.

On Thu, Nov 30, 2017 at 6:11 AM, Harshal Dhumal <harshal.dhumal@enterprisedb.com> wrote:
Hi,

Unlike flask login-manager flask-security does not provide facility to pass custom view
function to any of callbacks like change/reset/forgot password. So we cannot
handle any exceptions occurred during changing/resetting password.
Only way we can handle such exceptions is writing our own routes for these callbacks and
add addition code to handle such exceptions. 

-- 
Harshal Dhumal
Sr. Software Engineer

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Attachment

pgadmin-hackers by date:

Previous
From: Murtuza Zabuawala
Date:
Subject: [pgAdmin4][Patch]: To fix the issue in Debugger module
Next
From: Dave Page
Date:
Subject: pgAdmin 4 commit: Fix regression tests for password reset in servermod