Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
14 changes: 4 additions & 10 deletions app/routers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,10 @@ async def logout(request: Request, response: Response):
I usually open a new tab/window to reset basic auth. We likely
need a logout button to be handled somehow in javascript.
"""
response.delete_cookie("basic")
response.delete_cookie("bearer")
response.delete_cookie("access_token")
data = helpers.get_page("index.md")
return templates.TemplateResponse(
"index.html",
{
"request": request,
"data": data,
},
raise HTTPException(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still want to give the user a good experience here - the initial intention to redirect somewhere was to do that. Right now this logout function seems to just raise an exception but I'm not sure it does anything?

Copy link
Contributor Author

@khoing0810 khoing0810 Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. It was just the old code I did last year but unable to get to work on git workflow issue until now. The exception is raised with 401 status code to invalidate current credential, and hence, logging out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better user experience, I think we should start looking into another authentication method since Basic Auth is not designed to handle logout functionality (here's the rationale I found: https://stackoverflow.com/a/233551) but I'm open to any suggestion!

status_code=401,
detail="Logged out successfully",
headers={"WWW-Authenticate": "Basic"},
)


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.black]
profile = "black"
exclude = ["^env/"]
exclude = "^env/"

[tool.isort]
profile = "black" # needed for black/isort compatibility
Expand Down
55 changes: 34 additions & 21 deletions templates/include/topnav.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<button type="button" id="sidebarCollapse" class="btn btn-info">
<i class="fas fa-align-left"></i>
</button>
{% if title %}<h3 style="margin-left:20px">{{ title }}</h3>{% endif %}
<div class="container-fluid">
<button type="button" id="sidebarCollapse" class="btn btn-info">
<i class="fas fa-align-left"></i>
</button>
{% if title %}
<h3 style="margin-left: 20px">{{ title }}</h3>
{% endif %}

<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item {{'active' if active_page == 'submit_job' }}">
<a class="nav-link" href="/jobs/submit">Submit</a>
</li>
<li class="nav-item {{'active' if active_page == 'jobs' }}">
<a class="nav-link" href="/jobs">Jobs</a>
</li>
<li class="nav-item {{'active' if active_page == 'api' }}">
<a class="nav-link" href="/docs">API</a>
</li>
</ul>
</div>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item {{'active' if active_page == 'submit_job' }}">
<a class="nav-link" href="/jobs/submit">Submit</a>
</li>
<li class="nav-item {{'active' if active_page == 'jobs' }}">
<a class="nav-link" href="/jobs">Jobs</a>
</li>
<li>
<a class="nav-link" href="/logout">Logout</a>
</li>
<li class="nav-item {{'active' if active_page == 'api' }}">
<a class="nav-link" href="/docs">API</a>
</li>
</ul>
</div>
</div>
</nav>