coherence
coherence copied to clipboard
Support different kinds of users with Coherence
For instance, one might need authentication for sellers
and buyers
.
Or admin
, and author
?
I think that should be delegated to Authorization like with Canary https://github.com/cpjk/canary
smpallen99 has some repos where he integrates it all, also check whatwasit with --whodoneit really awesome stuff with ExAdmin and Coherence, I need to put all the pieces together to do my own kind of wiki with admins staff and users.
Yes I'm looking at Canary for handling authorization & privileges.
But I assumed Canary would come in the picture only after the user account is created.
With default Coherence, both sellers & buyers could get the same login/signup UI, and be put in the same users
model. Can we add different models to Coherence?
Coherence should already provide some limited support for multiple user models. Although I have not tested it directly on Coherence, the Session plug does have support for providing a db_model
option. I created Coherence based on a previous designed I use on another project which has 2 separate user models.
You will need to create separate routes for each login, either in the same endpoint, or separate endpoints (my project used separate endpoints since the they used different databases). You will also need to a separate session controller, or adapt the current session controller to handle multiple use models.
As well a providing the db_model
option to the session plug, you can also provide a login
callback For example, assuming you have setup the default authorization for buyers and want to setup a second user model for sellers, you could do the following in your router:
pipeline :browser_seller do
plug :accepts, ["html"]
# ...
plug Coherence.Authentication.Session, db_model: MyProject.SellerUser
end
pipeline :protected_seller do
plug :accepts, ["html"]
# ...
plug Coherence.Authentication.Session, db_model: MyProject.SellerUser, login: MyProject.SellerSessionController.login/2
end
I will look at adding full support for multiple user models when I get some time.
I'm actually embarking on this feature for my application today, because I have a frontend and a backend, with admins on the backend, and customers on the frontend.
Customers have additional fields in the database that an admin doesn't (for example address, shipping details, etc).
I'll document as I go.
@joshuataylor Sounds great. Are you planning on submitting PR? If so, would be great to review design as you go.
any updates on this?
Im interested on this too, I want to build a Admin/Seller/Customer interface and with all the new shit going on with phx1.3 and ex1.4 I don't know where to start. Ffs, I can't even get basic Ecto belongs_to <> has_many right...
I'm going to need this in about a week too. So, expect an update soon.
Great @smpallen99 , I will be following along the repos...
Anyways, I don't want to nitpick, but have you taken a look at rummage-phoenix? it seems it solves doing a lot of the functionality desired from exadmin dashboards with much less boilerplate/input fields/ui noise
I don't know, I just like how sorting and filtering/search works, but not sure if could be added easily.
Thanks for all your open source elixir projects, you rock!
Hey @smpallen99 any updates on this? I'm trying to setup multiple user models in an umbrella application and I'm concerned that since coherence uses cookies to identify a logged in user, it maybe over-written / interchanged with the wrong user model.
@dsignr No updates yet. I have some WIP done for refactor that would allow namespaced coherence configuration. The driver for this is mainly to support coherence in umbrella apps. However, it would also allow multiple coherence schemas. However, I have not had time in the last few weeks to complete the refactor.
And now that Phoenix 1.3 has been released, with some major changes over the the previous rc's, I have more work to do just to properly support this latest release :(
Has anyone made any progress on this or have any examples of how this might be implemented with canary?
I would also be interested in something like this?
Any updates on this?
@smpallen99 are you still planning to implement this?