ever-co / ever-gauzy

Ever® Gauzy™ - Open Business Management Platform (ERP/CRM/HRM/ATS/PM) - https://gauzy.co
https://gauzy.co
GNU Affero General Public License v3.0
2.16k stars 515 forks source link

Feature: Clients Invites #648

Open evereq opened 4 years ago

evereq commented 4 years ago

We have a few Epics related to organization clients: 1) ability for clients to login into Gauzy and see some information or make some actions (e.g. our company has some clients who want to get access to projects, employees, bonuses info, and many other) - https://github.com/ever-co/gauzy/issues/514 2) ability to invite clients to join Gauzy - this Epic

So, below is a description of 2)

On the Organization management Clients tab, we have a button "Add" which allows creating new Client for given Organization manually. However, it will be very useful to be able to "invite" clients into Gauzy, so they can register their own account, next to be able to login to Gauzy, communicate with a partner organization(s), see reports, statistics, employees tracking time and so on.

So we need to add the following:

1) button "Invite" on that Tab, to the right from the button "Add" which will open a popup to invite the client into Gauzy. Such an invite should have an input field for the client's email address. If the client invited, he should get an email with a link to join the Gauzy platform by registering an account. Such a link also should include the organization Id of the user who invited the client. After registration of client tenant and organization is done, the invite system should create a link between both organizations, where one is identified as "Client" for another. The most simple way to do it is to add a new field into organization_clients table called "clientOrganizationId" (default null) and add there client organization id after it (new organization for the client) gets created during invite process.

2) In the Card of each of the existed clients (who do not yet have registered account, i.e. not have clientOrganizationId != null), we should have a button "Invite", which will open a popup to invite that already existed client into Gauzy. It will only send an email with an invite link to the relevant client. Note: if no email entered for the client, invite button should show popup to enter client email with the button "Invite" (and of course we should update client record with such email address).

3) We should make client card clickable (unrelated to Invite feature we describe here) and it should redirect to separate Client page, where we will have different features available to work with a specific client, including the ability to view his profile page at Gauzy, to communicate with Client and so on.

rmagon commented 4 years ago

@evereq I've started work on this feature & have a few questions

On tenants (though it'll come much later but just want to be sure) :

  1. Will this client be created within the same tenant or will it be a new tenant altogether?

  2. If the client will be a new tenant, then when we start showing things only for a tenant, will the client organization be visible in the 'organizations' tab (technically it shouldn't be if the client is a new tenant)?

General

  1. What do we do if the email address already exists in the system as a user? (Maybe for the same tenant or maybe for different tenant etc.. ). I think for now we can just not allow them to add an email that already exists in the system.

  2. When an invite is sent, should we create a client in the db with state 'invited' & null clientOrganizationId or instead only create a separate table like _invitedclients. I would prefer the first one because the client might take time to register & we shouldn't wait for them signing up for an organization to create simple client one in our db.

evereq commented 4 years ago

@rmagon see my answers below:

On tenants

  1. Every time some client "accept" invite (by clicking the link in the email with invite), we should create a new tenant and new single admin "user" in such new tenant, unless some user with such email already exists in our DB. If user with such email already exists and have an only single organization, we need to set clientOrganizationId to that Org Id.

That means we also probably should have a field clientTenantId where we will store TenantId of the client, I missed this in the description above!

The more complex scenario would be if a user with same email has multiple organizations and so we don't know which one to connect. I think in this case, we will need to show something for the client in our UI (when he click on the invite link) so he can select which Org he wants to "connect" (we can't show such selection/list of Organization to user who sends invite because it's security issue! We can only as client to select from his Orgs)

  1. Nope, client Organization(s) should not be visible in the "organizations" tab I think. It's just that the client will have such an organization for herself, can login in to the Gauzy, see stats, etc. But we can't manage our client's organizations, only our own :)

General

  1. See answer above :) If email is used in our current tenant (not in some other tenant like described above), we will need later to generate an error saying that you want to invite a user which already registered in account :)

  2. Yes, let's create a client record in our tenant DB in any case with state invited and only if client actually register we set that clientOrganizationId to relevant value and change status

Let me know if you have more questions!

evereq commented 4 years ago

@rmagon also to give you idea how complex it will be after client logins (in his own tenant), please read https://github.com/ever-co/gauzy/issues/514 ;)

Basically in some sense, you were right when you asked about the visibility of organizations (and the data) between company and client organizations. There will be some more "connected" things there, but for now, for the invite feature, it's most important to just store such "connection" info so later we can use it to decide what we can show to both org and client org.

MuizNadeem commented 4 years ago

@evereq Are we good to close this issue or keep it open till we cover the scenarios where invited client pre-exists in the system as part of one or more tenants.

evereq commented 4 years ago

@MuizNadeem I would prefer to keep it open before we cover all cases

MuizNadeem commented 4 years ago

Sure 😃