Giter Club home page Giter Club logo

Comments (3)

TangleSpace avatar TangleSpace commented on August 14, 2024

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.

TangleSpace avatar TangleSpace commented on August 14, 2024

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.

fredzannarbor avatar fredzannarbor commented on August 14, 2024

from hydralit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.