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

Implemented logout functionality #60

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

khoing0810
Copy link
Contributor

user has to hit 'cancel' upon a popup after logging out

@vsoch
Copy link
Member

vsoch commented Aug 19, 2023

hey @khoing0810 ! It looks like you are bringing in commits that were from previous work (and squashed). The way to fix this is to keep your fork main branch absolutely in sync with the one here, and always checkout fresh. Let me know if you want some help to look at this / walk through this process - most projects won't be happy to just ignore (e.g., squash and commit) and will want to see a logical git history, so we should make sure you know how to do that. Happy weekend!

@khoing0810 khoing0810 force-pushed the authentication-resolve branch from 4949efe to 80fddf9 Compare February 24, 2024 19:26
@khoing0810 khoing0810 force-pushed the authentication-resolve branch from 80fddf9 to dce06e0 Compare February 24, 2024 19:36
@khoing0810
Copy link
Contributor Author

khoing0810 commented Feb 24, 2024

Resurrected this from the dead but I implemented the basic logout button after cleaning up the git workflow. Looking into approach that get it to stop raising the exception and redirected the page to home page

"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!

@khoing0810
Copy link
Contributor Author

khoing0810 commented Feb 29, 2024

This new implementation solves the issue of user logging out without being authenticated prior--when they try to log in again, they're met with 401 status code. The new functionality uses conditional appearance of 'Logout' button only when user is authenticated (logged in) to prevent them performing such action defined in first sentence.

@vsoch
Copy link
Member

vsoch commented Feb 29, 2024

Thanks @khoing0810 ! I should have time this weekend to review.

@vsoch
Copy link
Member

vsoch commented Mar 1, 2024

@khoing0810 I did a quick test, and exported my credentials:

export FLUX_USER=flux
export FLUX_TOKEN=flux
export FLUX_REQUIRE_AUTH=true

And basic auth does not work. It pops back to this screen:

image

and:

image

@vsoch
Copy link
Member

vsoch commented Mar 1, 2024

Here is a different approach to try (what I would do). Since we already have a database setup, get rid of the basic auth and needing to cache things in the browser and use JWT tokens, and then you add that to depends for each view. https://medium.com/@chnarsimha986/fastapi-login-logout-changepassword-4c12e92d41e2.

If that is too much then I can likely help and get started, but again maybe not immediately because I have a lot on my plate atm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants