Skip to content

Commit

Permalink
Added auth0 variable context processor fixs - openknowledge-archive#127
Browse files Browse the repository at this point in the history
  • Loading branch information
subhankar committed Dec 29, 2016
1 parent 83e2d5f commit a1883bd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 4 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def create_app():
Gravatar(app)

@app.context_processor
def s3_cdn_path():
return dict(s3_cdn=get_s3_cdn_prefix())
def populate_context_variable():
return dict(s3_cdn=get_s3_cdn_prefix(),
auth0_client_id=app.config['AUTH0_CLIENT_ID'],
auth0_domain=app.config['AUTH0_DOMAIN'])

return app
4 changes: 1 addition & 3 deletions app/auth/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ def callback_handling():

return render_template("dashboard.html", user=user,
title='Dashboard',
encoded_token=jwt_helper.encode(),
zappa_env=get_zappa_prefix(),
s3_cdn=get_s3_cdn_prefix()), 200
encoded_token=jwt_helper.encode()), 200
except Exception as e:
app.logger.error(e)
return handle_error('GENERIC_ERROR', e.message, 500)
Expand Down
8 changes: 2 additions & 6 deletions app/site/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ def index():
return render_template("dashboard.html", user=user,
title='Dashboard'), 200
return redirect(request.headers['Host'] + '/logout')
return render_template("index.html", title='Home',
auth0_client_id=app.config['AUTH0_CLIENT_ID'],
auth0_domain=app.config['AUTH0_DOMAIN']), 200
return render_template("index.html", title='Home'), 200
except Exception:
return redirect(url_for('.logout'))

Expand All @@ -59,9 +57,7 @@ def logout():
302:
description: Load the Home Page
"""
return render_template("logout.html", title='Home',
auth0_client_id=app.config['AUTH0_CLIENT_ID'],
auth0_domain=app.config['AUTH0_DOMAIN']), 200
return render_template("logout.html", title='Home'), 200


@site_blueprint.route("/<publisher>/<package>", methods=["GET"])
Expand Down
8 changes: 6 additions & 2 deletions tests/site/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ def create_app(self):
return create_app()

def test_should_have_s3_cdn_value(self):
response = self.client.get('/')
print(response)
self.client.get('/')
self.assert_context("s3_cdn", get_s3_cdn_prefix())

def test_should_have_auth0_client_id(self):
self.client.get('/')
self.assert_context("auth0_client_id",
self.app.config['AUTH0_CLIENT_ID'])

0 comments on commit a1883bd

Please sign in to comment.