Comments (3)
There wouldn't be any issue with using that authentication, looks pretty good. Basically put the user creation behind the sign-up _save_signup method (for example i currently just print the collected details), put the call to check the login details in the _check_login method of the login app. To make sure the cached authentication from the simple auth logs the user out when the logout button is hit, you'd need to check the transition sequence after the app.run(complex_nav) call and if the user clicked the logout button, then run the logout method of the auth framework there. For example you can check where the user was and navigated to internally by checking the internal Hydralit variables app.session_state.previous_app and app.session_state.selected_app, put these lines after the app.run(complex_nav) in the example to see what i mean.
#print user movements and current login details used by Hydralit
username = str(app.session_state.current_user)
user_access_level = int(app.session_state.allow_access)
print(app.session_state.previous_app,'- >', app.session_state.selected_app)
print(user_access_level,'- >', username)
from hydralit.
with the 1.0.8 release, i put a few convenience functions in to make integrating with an external security provider easier, please look at the example repo, in particular, you can now specifically attach functions to be called when a user logs in and logs out by injecting them into the Hydralit parent.
#we can inject a method to be called everytime a user logs out
#---------------------------------------------------------------------
@app.logout_callback
def mylogout_cb():
print('I was called from Hydralit at logout!')
#---------------------------------------------------------------------
#we can inject a method to be called everytime a user logs in
#---------------------------------------------------------------------
@app.login_callback
def mylogin_cb():
print('I was called from Hydralit at login!')
#---------------------------------------------------------------------
#-----if we want to auto login a guest but still have a secure app, we can assign a guest account and go straight in
#check if this is first open
user_access_level, username = app.check_access()
if user_access_level == 0 and username is None:
app.set_access(1, 'guest')
#--------------------------------------------------------------------------------------------------------------------
Also a cleaner way to check the user details from the parent,
#check user access level to determine what should be shown on the menu
user_access_level, username = app.check_access()
Lastly, if you want to do some diagnostics, you can monitor the application transitions and the user details by adding this under the run call of the parent.
#print user movements and current login details used by Hydralit
#---------------------------------------------------------------------
# user_access_level, username = app.check_access()
# prev_app, curr_app = app.get_nav_transition()
# print(prev_app,'- >', curr_app)
# print(int(user_access_level),'- >', username)
#---------------------------------------------------------------------
from hydralit.
from hydralit.
Related Issues (20)
- Set menu_items from page config HOT 1
- Demo on Heroku is down HOT 1
- hydralit 1.0.12 and streamlit 1.9.0 HOT 5
- How to disable the (huge) "Now Loading YOUR.APP" HOT 1
- Login and Logout through Hydralit! HOT 1
- Latest streamlit version not supported HOT 3
- The uploaded video file co-exists among different apps
- How to make navbar full-length of screen and placed all the way at the top? HOT 1
- type objct 'Server' has not attribute 'get_current' HOT 2
- Update for using `st.session_state` HOT 3
- Import Syntax Issues With Streamlit 1.12.2 HOT 4
- Error when running app.run() HOT 1
- Sites deployed on Heroku are not working
- Keyed widget values are lost when switching the pages HOT 1
- AttributeError: st.session_state has no attribute "allow_access". HOT 1
- When resizing navbar is cut off.
- Doesn't work with streamlit cloud
- Nav Bar oriented vertically rather than horizontally HOT 1
- The Navbar changes when st.title added HOT 1
- AttributeError in add_app Method when Using Hydralit HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hydralit.