bugfix: use endpoint-for-function for more robust endpoint matching
This commit is contained in:
parent
474458c623
commit
4d1f70b1e6
|
@ -69,7 +69,8 @@ class MicropubClient:
|
|||
https://indieauth.com/auth if none is provided.
|
||||
"""
|
||||
redirect_url = flask.url_for(
|
||||
self._authenticated_handler.func_name, _external=True)
|
||||
self.flask_endpoint_for_function(self._authenticated_handler),
|
||||
_external=True)
|
||||
return self._start_indieauth(me, redirect_url, next_url, None)
|
||||
|
||||
def authorize(self, me, next_url=None, scope='read'):
|
||||
|
@ -89,7 +90,8 @@ class MicropubClient:
|
|||
https://indieauth.com/auth if none is provided.
|
||||
"""
|
||||
redirect_url = flask.url_for(
|
||||
self._authorized_handler.func_name, _external=True)
|
||||
self.flask_endpoint_for_function(self._authorized_handler),
|
||||
_external=True)
|
||||
return self._start_indieauth(me, redirect_url, next_url, scope)
|
||||
|
||||
def _start_indieauth(self, me, redirect_url, next_url, scope):
|
||||
|
@ -296,6 +298,12 @@ class MicropubClient:
|
|||
token_endpoint and token_endpoint['href'],
|
||||
micropub_endpoint and micropub_endpoint['href'])
|
||||
|
||||
@staticmethod
|
||||
def flask_endpoint_for_function(func):
|
||||
for endpt, view_func in flask.current_app.view_functions.items():
|
||||
if func == view_func:
|
||||
return endpt
|
||||
|
||||
|
||||
class AuthResponse:
|
||||
"""Authorization response, passed to the authorized_handler endpoint.
|
||||
|
|
Loading…
Reference in New Issue