Skip to content

Commit

Permalink
Fix firebase auth example (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen committed Aug 29, 2024
1 parent 1badccb commit 5998909
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ class State:


def on_auth_changed(e: mel.WebEvent):
print("AUTH", e.value)
firebaseAuthToken = e.value
if not firebaseAuthToken:
me.state(State).email = ""
return

decoded_token = auth.verify_id_token(firebaseAuthToken)
if decoded_token["email"] != "allowlisted.user@gmail.com":
raise me.MesopUserException("Invalid user: " + decoded_token["email"])
# You can do an allowlist if needed.
# if decoded_token["email"] != "allowlisted.user@gmail.com":
# raise me.MesopUserException("Invalid user: " + decoded_token["email"])
me.state(State).email = decoded_token["email"]
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ firebase.initializeApp(firebaseConfig);
const uiConfig = {
// TODO: change this to your Mesop page path.
signInSuccessUrl: '/web_component/firebase_auth/firebase_auth_app',
signInFlow: 'popup',
signInOptions: [firebase.auth.GoogleAuthProvider.PROVIDER_ID],
// tosUrl and privacyPolicyUrl accept either url string or a callback
// function.
Expand Down

0 comments on commit 5998909

Please sign in to comment.