Skip to content

Commit

Permalink
Better state handling on OAuth call
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Dec 28, 2018
1 parent 47d6894 commit cbe15d0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/appier_extras/parts/admin/part.py
Expand Up @@ -834,7 +834,7 @@ def oauth_authorize(self):
params = dict(
code = oauth_token.authorization_code,
scope = " ".join(oauth_token.tokens),
tokens = oauth_token.tokens,
state = state
)
)

Expand All @@ -857,9 +857,14 @@ def oauth_authorize(self):
code = exception.code if hasattr(exception, "code") else None
error_message = exception.message if hasattr(exception, "message") else None
error_code = OAUTH_ERROR_CODES.get(code, "server_error")
kwargs = dict(error = error_code, error_description = error_message)
if state: kwargs["state"] = state
return self.redirect(redirect_uri, **kwargs)
return self.redirect(
redirect_uri,
params = dict(
error = error_code,
error_description = error_message,
state = state
)
)

@appier.ensure(context = "admin")
def do_oauth_authorize(self):
Expand Down Expand Up @@ -890,7 +895,7 @@ def do_oauth_authorize(self):
params = dict(
code = oauth_token.authorization_code,
scope = " ".join(oauth_token.tokens),
state = state,
state = state
)
)

Expand Down

0 comments on commit cbe15d0

Please sign in to comment.