-
-
Notifications
You must be signed in to change notification settings - Fork 605
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
authentication issues with on_air (RedirectResponse not working properly) #1517
Comments
@Smug246 |
@falkoschindler So id expect it to just move on to the / page but it doesnt. check the edited code. it currently just sits on the same page wether the username, password are right or not |
Strange. It works on my machine. After 1.5 seconds I'm redirected to "/". |
are you definitley using the on air link thats generated. because its only on that link it doesnt work. it works normally without that |
What is the url if you see this error? |
That is odd. In #1501 I've added a middleware which should add the correct prefix. Are you sure this is the url you end up when starting you demo with 1.3.12 and open the On Air url? Would have been the expected result with 1.3.11. With 1.3.12 I get https://on-air.nicegui.io/devices/vk7MeJ7wlogin/ (eg. the / before login is missing). |
Maybe you have a virtual env in the dir and the pip version is not used? Try from nicegui import __version__
print(__version__) |
Wow. What a mystery. I'm not very confident that my bugfix ec77362 will solve it for you. But it is definitely fixing the original problem which I could reproduce. We will release 1.3.13 shortly. Let's try that and hope for the best. |
thanks for trying, i hope 1.3.13 works |
Ok, 1.3.13 is just released. I hope it helps. |
@Smug246 have you found the time to try this with 1.3.13? |
i'll test today when i'm home and let you know |
hi @rodja im still having problems after testing today. but its slightly different. when using on_air everytime a login is successful it will write authenticated true in the .nicegui directory, however on_air doesnt seem to track that storage so everytime i login a new session is made. and i can never login without going back to the login page. from nicegui import ui, app
import asyncio
from fastapi.responses import RedirectResponse
@ui.page('/')
def home():
if not app.storage.user.get('authenticated', False):
return RedirectResponse('/login')
@ui.page('/')
def login():
async def try_login():
try:
input_password = password.value
actual_username = 'admin'
actual_password = 'admin'
if input_password == actual_password:
app.storage.user.update({'username': actual_username, 'authenticated': True})
ui.notify('Login Successful', color='positive')
await asyncio.sleep(1.5)
ui.open('/')
else:
ui.notify('Invalid username or password', color='negative')
username.set_value('')
password.set_value('')
except Exception as e:
print(e)
ui.query('body')
with ui.card().style('width: 250px;').classes('absolute-center'):
username = ui.input('Enter Your Username').style('width: 225px;')
password = ui.input('Enter Your Password', password=True, password_toggle_button=True).on('keydown.enter', try_login)
ui.button('Log In', on_click=try_login)
ui.run(on_air=True, reload=False, storage_secret='secret') EDIT: i've just deployed my site using docker and fly.io and the same problem occurs but with just: ui.run(title='Freight Forever (Beta)', storage_secret='Freight_Forever_Secret', reload=False) |
That looks like a completely other issue that the non-working RedirectResponse. Could you repost this a a new issue? |
Description
when on_air=True authentication doesnt seem to work.
minimal reproduction:
The text was updated successfully, but these errors were encountered: