Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix firebase logout #97

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions client/src/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ if (params.get("email")) {
}

const sendTokenToServer = (token) => {
document.cookie = `token=${token}`;
window.location.replace('/auth_token');
window.location.replace(`/auth_token?token=${token}`);
}

// get firebase auth status
Expand All @@ -22,7 +21,6 @@ auth.onAuthStateChanged((user) => {
}

if (params.get('logout') === '1') { // force logout from firebase
document.cookie = 'token=';
signOut(auth);
return;
}
Expand Down
13 changes: 5 additions & 8 deletions server/cp/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from flask_babel import gettext
from google.auth.transport import requests
from newsroom.auth.utils import sign_user_by_email
from newsroom.auth.views import logout as _logout

TIMEOUT = 5

Expand All @@ -16,7 +17,7 @@
@blueprint.route("/auth_token")
def token():
claims = None
token = flask.request.cookies.get('token')
token = flask.request.args.get('token')
if token:
try:
claims = google.oauth2.id_token.verify_firebase_token(
Expand All @@ -32,17 +33,13 @@ def token():
email = claims["email"]
return sign_user_by_email(email)

return flask.redirect(flask.url_for("auth.index"))
return flask.redirect(flask.url_for("auth.login"))


@blueprint.route("/logout")
def logout():
flask.session.pop("user", None)
flask.session.pop("name", None)
flask.session.pop("user_type", None)
resp = flask.redirect(flask.url_for("auth.login", logout=1))
resp.delete_cookie("token")
return resp
_logout()
return flask.redirect(flask.url_for("auth.login", logout=1))


@blueprint.route("/cp_reset_password_done")
Expand Down
10 changes: 4 additions & 6 deletions server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,15 @@


BLUEPRINTS = [
"cp.auth", # we need this one loaded before newsroom.auth to make it override logout
"cp.mgmt_api_docs",
] + [
blueprint
for blueprint in DEFAULT_BLUEPRINTS
if blueprint
not in ["newsroom.design", "newsroom.monitoring", "newsroom.news_api.api_tokens"]
]
BLUEPRINTS.extend(
[
"cp.mgmt_api_docs",
"cp.auth",
]
)


CORE_APPS = [
app
Expand Down