Using the same login Users table across Apps

Hello Again Friends:

I was thinking about creating an App with no Forms, whose only purpose is to store Data-Tables for deployable Apps that will share them. This data-only App will never run and never be deployed. Deployable Apps that share this data will have minor variations that are not yet knowable.

With that in mind, can the special Users Data-Table (the one referenced for logins) in that data-only App, be used as the special Users Data-Table (the one referenced for logins) in the deployable Apps, perhaps with the caveat that they all apply the same login model (e.g. they’d all use, say, Magic Email Link).

Sorry for the lengthy question, which is somewhat architectural in nature.

Thoughts and gotchas are welcome.

Thank you!

The short answer is “yes.” But I haven’t done it yet myself, and there may be gotchas others have run into. One is that I think it’s not yet possible to use the Beta IDE to share Tables between apps (just the initial setup step). But these docs point the way how to do it in the classic IDE: Anvil Docs | The Users Table

1 Like

Hi @hugetim Thank you for the reply. :slight_smile: Indeed, I saw that and am using the classic IDE for the creation step. Thank you for the tip. @hugetim PS: That was a nice document share. I’ve read a ton of docs, but that one escaped me. :smiley:

1 Like

I often find the document I need most, is the one I don’t find. :sweat_smile:

3 Likes

I use them, its quite simple since anvil/python at times can be so simple that your wouldn’t initially think it would work.

Lets say you have two apps, A and B, and you want them to share the same users table.

Lets also say you already have the users service installed, working, and have user(s) who have logged in at least once in App ‘A’, but you want app ‘B’ to use the same users.

  1. Add the users service to app B
  2. Log In to App B by creating a new user. (This will cause the ‘Auto create columns’ to create whatever the Users table needs in App B)
  3. Rename the users table to something else like ‘Users_old’ or whatever.
  4. Using the Classic IDE (If the Beta IDE still has not implemented sharing tables by the time this is read), Click the Plus + sign in the data tables to add a new table and navigate to App ‘A’ s users table and select it to share the same users between ‘B’ and ‘A’.
  5. Optional: Compare the users_old with the linked ‘new’ Users table to see if there are any columns missing from the linked table. Then You can delete the ‘_old’ one.

That’s really all I have ever done and it works.

Your users table will now only be as secure as your least secure app! :partying_face:

5 Likes

@ianb Thank you. What a delightful step-by-step. It makes total sense and reaffirms what I need to do. Thank you. :slight_smile:

1 Like