🧙♂
Users
Personalise your app
When you share your app with specific users, you can get information about their Databutton user by using
import databutton as db
user = db.user.get()
The user object looks like this
class User(BaseModel):
user: str
email: str
import databutton as db
import streamlit as st
user = db.user.get()
st.write(f"Hello, {user.name}")
You can utilize Databutton storage in harmony with
db.user.get()
role-based access in your app.Example: Admin access
import databutton as db
import streamlit as st
# user_json looks like this
# {
# "admins": ["[email protected]", "[email protected]"]
# }
users_json = db.storage.json.get('users')
user = db.user.get()
if user.email not in users_json['admins']:
st.write('This is only available to admins!')
st.stop()
st.write(f"Hello, {user.name}")
Last modified 18d ago