GithubHelp home page GithubHelp logo

Comments (11)

marshall007 avatar marshall007 commented on June 3, 2024 2

To clarify, I'm saying:

class UserCollection extends Collection {
  current() { /* ... */ }
}

horizon.users = new UserCollection(...)

from horizon.

deontologician avatar deontologician commented on June 3, 2024

@Tryneus @coffeemug is this issue useful for tracking purposes or is it superseded by the work done on the server for auth?

from horizon.

coffeemug avatar coffeemug commented on June 3, 2024

This is for tracking purposes and not superseded. The big question is what the user management API will look like (e.g. how do I list users?) and whether we'll have a specialized one or let developers access user tables through the standard fusion API.

from horizon.

deontologician avatar deontologician commented on June 3, 2024

Right now the implementation of authentication has an internal table that tracks users. I guess an outstanding question is whether we should:

  • A) move the metadata table to be an app level table
    • pro: only one table, can use existing horizon commands to manage users
    • con: this would be the first table we create for a user. They may mess it up so horizon can't understand it
  • B) allow both an internal table for users and an app table for users if the app creator wants one
    • pro: internal table is always understandable by horizon. App table is exactly what the app developer expects, with no magic.
    • con: we lose atomic operations on users, since data is split over two tables for one conceptual entity
  • C) ensure users are managed entirely internally by horizon, perhaps adding special commands for modifying a user
    • pro: App developers can't break the user table, we can store whatever internal data we want, and expose only operations that are safe/valid on users.
    • con: maybe inflate the api a bit

I'm partial to C, we might make a user look like a pseudo-collection:

horizon.user(userId).update({foo: 'bar'})

The internal user document would look like:

{ "id": 1,
  // auth/permissions related fields here
  "appData": {
    "foo": "bar"
  }
}

from horizon.

deontologician avatar deontologician commented on June 3, 2024

ping @Tryneus

from horizon.

deontologician avatar deontologician commented on June 3, 2024

Ok, so we've settled on pseudo-tables, roughly as described in #151 . The client is also going to add a .currentUser().fetch() .currentUser().watch() method that looks at the user id in the jwt received in the handshake, and then queries the user table appropriately.

from horizon.

marshall007 avatar marshall007 commented on June 3, 2024

@deontologician since the users collection is available by default and there are probably going to be additional operations that only apply to the users collection, we could expose it statically:

horizon.users == horizon('users')
horizon.users.current() == horizon('users').get(CURRENT_USER_ID)

I can see this being useful for other terms/helper methods like horizon.users.active().watch() for observing users who are currently "online".

from horizon.

deontologician avatar deontologician commented on June 3, 2024

I think it'd be nice to support the normal table interface on it as well, so we don't have to duplicate things. Are you thinking about both horizon.users and horizon('users') existing?

from horizon.

marshall007 avatar marshall007 commented on June 3, 2024

@deontologician I certainly think people would expect horizon('users') to work too, but I was thinking horizon.users would be an instance of UserCollection, extended with additional methods like .current(). We'd have to add a special case in the Collection constructor in order for horizon('users') to return the correct instance type.

from horizon.

deontologician avatar deontologician commented on June 3, 2024

Cool, that seems reasonable

from horizon.

deontologician avatar deontologician commented on June 3, 2024

Bug fixed

from horizon.

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.