Topic: Multi-client application: user handling

Hi,

I plan an application for multiple clients. The URLs will be for example like:
www.myapp.com/client1, www.myapp.com/client2, ...

Each client can have multiple users (belonging to one or multiple roles). A user for client 1 should (of course) not be able to login in for client2.
The users are not created by a registration form but by other users of that client.
In addition to that there have to be (a few) users that do not belong to any client. These users should then be able to create users for each client.

So the most important requirements are: log-in, log-out, creation of users, separation of data among the clients, password reset

Can you give me some advise how to do that? Is devise a good starting point? Or should I better create my own solution?
Maybe you even know tutorials that cover this issue!?

Thanks a lot

Re: Multi-client application: user handling

OK, I have be playing around with Devise a little.
In my routes.rb I have:

  scope "/:kreis" do
    devise_for :users
    resources :projects
  end

In order to make Devise work with this scope, I had to add the following to the application controller:

  def default_url_options
    { :kreis => params[:kreis] }
  end

When I visite myapp.com/client1 and click on the login link, I am directed to myapp.com/client1/users/sign_in - as I expected it. But after the successful login I am redirected to myapp.com/?client=client1 instead of myapp.com/client1.
Moreover I am also logged in for all the other clients...
Any ideas how to fix that?

Thanks in advance...

Re: Multi-client application: user handling

I'm not too knowledgeable (yet), but have you considered using sub-domains instead? Instead of having myapp.com/client1 you would have client1.myapp.com. There is some railscasts that explain subdomains: http://railscasts.com/episodes/221-subd … in-rails-3 (using Rails 3) AND http://railscasts.com/episodes/123-subdomains (using the plugin subdomain-fu).

As far as managing separate lists of users for various clients with devise, maybe there should be a client model that has_many users and users belong_to a client.

Unfortunately, I'm not knowledgeable enough yet to give you example code for Devise, but hopefully those ideas help.

Change is a vector. You can have all the change in the world, but if it doesn't go in the right direction, what good is it? | techonamission.com