Skip to content
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
7 changes: 7 additions & 0 deletions kernelboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ def unauthorized():
api = create_api_blueprint()
app.register_blueprint(api)

# Redirect /v2/* routes to /* for SEO (v2 was removed but Google still indexes it)
@app.route("/v2/")
@app.route("/v2/<path:path>")
def redirect_v2(path=""):

return redirect(f"/{path}", code=301)

@app.errorhandler(401)
def unauthorized(_error):
return redirect("/401")
Expand Down
2 changes: 1 addition & 1 deletion kernelboard/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def callback(provider: str):
stores display fields in session, logs the user in, and redirects to the SPA.
"""
if not current_user.is_anonymous:
return redirect("/v2/")
return redirect("/")


provider_data = app.config["OAUTH2_PROVIDERS"].get(provider)
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_auth_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_callback_already_logged_in(client):

response = client.get("/api/auth/discord/callback")
assert response.status_code == 302
assert response.headers.get("Location") == "/v2/"
assert response.headers.get("Location") == "/"


def test_callback_unknown_provider(client):
Expand Down Expand Up @@ -153,7 +153,7 @@ def test_callback_happy_path(client):
"api/auth/discord/callback?state=123&code=456"
)
assert response.status_code == 302
assert response.headers.get("Location") == "/v2/"
assert response.headers.get("Location") == "/"


def test_logout(client):
Expand Down
Loading