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

Cannot login in fastapi-webapp-with-auth #22

Open
RuiNov1st opened this issue Aug 20, 2023 · 2 comments
Open

Cannot login in fastapi-webapp-with-auth #22

RuiNov1st opened this issue Aug 20, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@RuiNov1st
Copy link

Hello, I've tried your code on 2022-04-14-fastapi-webapp-with-auth.
But when I enter username and password and submit, it still redirect to home and show "You are NOT logged in". But in terminal, log says "Login successful!!!!".
And when I try to access /private, it show "AttributeError: 'str' object has no attribute 'removeprefix'".
Is there any mistake in my operation and how can I fix it? Thanks!

@RuiNov1st
Copy link
Author

Well. It seems that I can handle it. In function decode_token, token = token.removeprefix("Bearer").strip() could be replaced by for example:

if token.startswith('Bearer'):
        token = token[len('Bearer'):].strip()

because the methodstr.removeprefix() support only python 3.9+. And I use python 3.8.
And after I modified it, it could login successfully.
Sorry for the native question.

@SamEdwardes
Copy link
Owner

No bad questions! Thank you for starting the issue and sharing your fix. I should document the minimum python version to help future users!

@SamEdwardes SamEdwardes added the enhancement New feature or request label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants