Giter Site home page Giter Site logo

Generic state support about userbase HOT 19 OPEN

fenske avatar fenske commented on May 30, 2024 2
Generic state support

from userbase.

Comments (19)

notrab avatar notrab commented on May 30, 2024 3

It would be useful to have some kind of "global" database that all users can interact with by default.

For example, I want to allow users to comment on blog articles, and I want those comments to be retrievable by the Admin SDK to display on the page to guest users. But only authenticated users can interact with it.

Perhaps some built-in permissions around the items you add can be modified by you...

from userbase.

j-berman avatar j-berman commented on May 30, 2024 3

Done πŸ˜ƒ

from userbase.

j-berman avatar j-berman commented on May 30, 2024 2

Following up, working on a feature that I believe satisfies all use cases requested above (except item-level permissions, saving that for #208)!

Will soon be able to make data stored through the SDK available to any user of the SDK.

@fenske your use case will definitely be ready soon!

@notrab following up on your use case, I'm wondering if you're thinking about authenticating your users beyond just checking that your users are signed in. For example, do you only want paid users to be able to comment, or users with some special value in their protectedProfile to be able to? Or do you only want to allow users who are are signed in to your app to comment?

from userbase.

j-berman avatar j-berman commented on May 30, 2024 2

Happy to push it to the top of the priority list. It's been sitting on my mind personally. Think I may be able to get it done this weekend.

from userbase.

notrab avatar notrab commented on May 30, 2024 1

@j-berman awesome work!

To answer your question - it might make more sense for now to restrict it to signed in users? Doing this I'm guessing would reduce the need for any workarounds later with any user level permissions.

from userbase.

j-berman avatar j-berman commented on May 30, 2024 1

@notrab

Do you see such problems if the protectedProfile path was taken?

So basically seems like there are 2 problems here:

  1. needing to call signUp() in the background to create a guest user in order to access global data.

  2. not preventing blog article comments from unauthenticated users server-side.

The 2nd problem is absolutely preventable using the protectedProfile route. Could definitely offer a way to only allow users with a particular value in their protectedProfile to comment on articles server-side. Will make sure this is possible with the initial release of this feature.

Unfortunately the 1st problem isn't solvable via the protectedProfile route alone.

Userbase at its core has a simple API, and has very low barrier to entry. I think we should keep this for as long as possible, so avoiding the recommendation to users to make calls to signup in the background for guest users.

I agree. And the idea to make the global data available via an Admin SDK would solve this issue. Will think on this some more.

from userbase.

j-berman avatar j-berman commented on May 30, 2024 1

@notrab been thinking on this lately...

  • allowing non-signed in users to access global data is now on the roadmap.
  • getting userbase-js to work in node would enable admins to access global data from a server. Definitely want to get this done soon too :)

from userbase.

Fubinator avatar Fubinator commented on May 30, 2024 1

We would be very interested in node support as well. We're currently building something in node.js with puppeteer, which works, but is slow and quite tedious.

from userbase.

j-berman avatar j-berman commented on May 30, 2024

Question on this, do you want your users to be able to modify this data in a way that all other users are able to see that user's modifications, such as a means for users to add a coding challenge to the list of available coding challenges for all other users?

Or alternatively, will you have a static set of generic data that all users have access to, such as a static list of coding challenges?

from userbase.

fenske avatar fenske commented on May 30, 2024

I believe I want a way to store and access non-user specific data that only I can control.

from userbase.

j-berman avatar j-berman commented on May 30, 2024

Got it, we'll keep this feature in mind in our roadmap!

For now, a suggestion: you could serve this data to your users the same way you serve your web app to your users. Wherever you're hosting your site, host this data as well. Does that make sense?

from userbase.

j-berman avatar j-berman commented on May 30, 2024

Got it, sounds good!

One thing I’m thinking, it’s a fairly large lift to allow non-signed in users to interact with data.

You could work around this once the feature to access global data is released like this: if someone visits the blog as a guest, prior to loading the blog comments from the global data store, just call signUp() in the SDK with a randomly generated guest username and password. Your client could then check that the user is a guest user, and simply not display the field to add a comment to the article, all client-side.

I figure there isn't a ton of value-add in terms of security in preventing unauthenticated users from commenting on articles server-side for your use case, since anyone is able to sign up to an app today by calling the signUp() function in the SDK (and could therefore pretty easily become authenticated). If you wanted to use more complex logic to "authenticate" users beyond just checking that they're signed in, then there would be value-add in preventing unauthenticated users from commenting on the articles server-side.

That suggested workaround sound alright to you?

Edit: forgot to tag @notrab

from userbase.

notrab avatar notrab commented on May 30, 2024

@j-berman You're right. Do you see such problems if the protectedProfile path was taken?

One other use case, and I'm not sure if this PR would address it, but it would be super useful to be able to use this global database via the Admin SDK. Do you think the implementation here would impact the behaviour that would require? If so, I think the simplest path forward should be taken here.

Userbase at its core has a simple API, and has very low barrier to entry. I think we should keep this for as long as possible, so avoiding the recommendation to users to make calls to signup in the background for guest users. While this would work, could we maintain the developer experience by going the other route of protectedProfile?

from userbase.

j-berman avatar j-berman commented on May 30, 2024

@notrab Assuming non-signed in users could access global data directly through the client SDK, would you still have use for retrieving data via the Admin SDK?

from userbase.

notrab avatar notrab commented on May 30, 2024

@j-berman I think having data accessible through the Admin SDK would be beneficial, maybe for reporting, or some "admin dashboards". What do you think?

I'm trying to think of a real world use case to apply our discussion to.

If we go on the theme on a multi tenancy blogging platform...

User signs up, creates a blog, and can invite others to the blog to write posts.

These posts can be by any user that has some flag (TBD), and then on the frontend, you can query all posts on at build time through the Admin SDK to render the page statically.

Then anyone who signs up, can comment on these.

There could be some holes in that use case πŸ˜…

from userbase.

j-berman avatar j-berman commented on May 30, 2024

@notrab those use cases make sense! Someone also requested the same feature a while back so they could run a CRON job that reads or modifies the data. I'm sure there's a bunch more use cases. Was just curious if there was something in particular you wanted to do with it here :)

With the approach where non-signed in users can access global data directly through the client SDK, you could have an admin user that creates the global data that others could access while not signed in. In the example you gave, a user can create a blog other users could write posts to, and non-signed users could access the posts at page load.

I think either of the 2 approaches we're discussing here would take a large lift (1: allowing non-signed users to access global data directly through the client SDK, or 2: just allowing access of global data through an Admin SDK). And the 2 approaches don't really overlap in implementation. If there's not much desire for the 1st approach, and there's a strong push for the 2nd instead, not really much reason to go with the 1st it seems.

Selling the 1st approach a bit further: users would get real-time updates to the data out of the box, it would be much simpler for developers to figure out how to use (it's nearly identical to opening a normal database now), and it would maintain the serverless component.

from userbase.

j-berman avatar j-berman commented on May 30, 2024

PR #250 deployed in userbase-js v2.6.0!

The PR highlights how the main use cases discussed above could be accomplished.

Will keep this issue open in light of the above discussion regarding the ability for non-signed in users to access global data and/or enabling admins to access global data via an Admin SDK.

from userbase.

spiffytech avatar spiffytech commented on May 30, 2024

Where does Node.js support sit on the priority list? I'd just assumed Userbase supported Node, and my use cases include a lot of scheduled/triggered activities I'd expected I could run from the server.

from userbase.

Shubhampratapsingh avatar Shubhampratapsingh commented on May 30, 2024

@notrab @j-berman @fenske @jneterer Kindly help me in this usecase.
Use Case: There is a multi author blog app based on react and userbase. I have one database i.e "Blogs".
All the user create their blog post in the same database.
Currently only creator are able to read and write blog post.
But I want every user to just read other blog post and only blog post creator can edit or delete that.
Share database not working, it's giving error as ShareTokenNotAllowed, may be because i am using only one database for every user to write blog post.
Issue raise with ticket #418 .

How can i achieve this feature?
Also can i do it using only client sdk?

from userbase.

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.