1

Currently we support one single account per customer. This means that we have a Profile associated with the membership UserID that contains all the company data.

We now need to allow multiple account for single customer. The scenario is the following: the company owner purchases the service: he/she registers using ASP.NET MVC membership and a customer record associated to the UserID is created, then it manually sends invitation to some of his/her employees to register and get access to the company account.

How would you implement this is ASP.NET MVC 4?

Thanks.

abenci
  • 8,422
  • 19
  • 69
  • 134

1 Answers1

1

Your question is not clear enough, you didn't say about the multiple account for single customer and what is the role of each account(costumer)..

If you mean that you want to make a third user : employee , so you can work width roles see this example:

http://www.codeproject.com/Articles/578374/AplusBeginner-splusTutorialplusonplusCustomplusF

example of creating user with roles :

http://www.codeproject.com/Articles/1075134/ASP-NET-MVC-Security-And-Creating-User-Role and you should authorized each controller or class with this attribute:

for example:

[Authorize(Roles="employee")]

or

[Authorize(Roles="admin")]

this enable you to detect the type of this user ...

And if you want to make multi account for single customer you can work width roles and add a role to each type of customer you want to create..

  • Adding a role may help but how I connect it to the main company profile? – abenci Apr 04 '16 at 10:56
  • In your controller ,profilecontroller for example, you can use the attrubute (Authorized(Roles="employee")),then bring and prepare the data that depend to a specific user (the current user<-->the online user<-->the authenticated user), then you can return a view (profile) to this user... **Note:in your C# classes you can check the role of the user logged in** –  Apr 04 '16 at 11:12
  • This is for roles and how you can hide some pages from some user...But if you want to relate the data in the compnay to users or employees (the user that create this application or who edit the page ..for example), so here you should relate this data in your database tables...Your database must be prepared so your user have a relation with some table(data of he company) –  Apr 04 '16 at 11:16
  • Do you mean adding a db table that connect main users with employee users? – abenci Apr 04 '16 at 11:50
  • The Roles table made the relation between different type of users.. i really don't understand your idea..If you want to relate users or if you want to relate the users with the data (business of the company) ...I suggest to read about membership provider and it will become real for you...see this link about the table users and the table roles in database: [Link](http://techbrij.com/custom-roleprovider-authorization-asp-net-mvc) and this : [Link](http://www.c-sharpcorner.com/UploadFile/4b0136/working-with-simplemembership-in-Asp-Net-mvc/) –  Apr 04 '16 at 12:05
  • My idea is simple: you can have 7 users of the same company, one is the company owner the other are standard users. The company owner register first (and create the full profile), then invites relevant users to register as well. – abenci Apr 04 '16 at 13:18
  • okay then when you make table users and table roles and put relation between them your idea simple will be done..The table users contains all users(7 user) and contain foreign key from table role that define him as owner or standard user..read the links i mentioned and read the examples...and you can read about form authentication and membership provider in asp.net mvc 4 and you will find a simple example that could help you..and don't worry about the login of owner and how to make the invitation..when you implement the login form you will be able to make any operation with multi-user... –  Apr 04 '16 at 13:42
  • you can do it by one table only see this example [multi user](http://www.codeproject.com/Articles/408306/Understanding-and-Implementing-ASP-NET-Custom-Form)...But its better to make 2 table one for user and on for role because of the repetition .. –  Apr 04 '16 at 13:52