0

Use case

I am creating an e-commerce website where i need two different login page

  1. For Customer
  2. For Vendor/Retailer

For customer i am storing it in AspNetUsers table but i want to create logic for vendor table

My Question

How can i acheive two logins I want to create one more table for vendor and create session to login and logout. Can anyone give me the reference or any proper documentation which i can follow

Thanks.

Rabennarbe
  • 42
  • 10
  • 1
    sounds like a job for user roles. if you want to store additional information for vendors, you can create an additional table with a 1 to 1 mapping – Neville Nazerane Dec 18 '20 at 07:34
  • 1
    agree - user roles, you can redirect based on the role assigned to the user –  Dec 18 '20 at 07:40
  • 1
    May be you can see this [link](https://stackoverflow.com/questions/64370175/how-to-add-multiple-identity-and-multiple-role-in-asp-net-core/64421573#64421573) may helpful. – Yinqiu Dec 18 '20 at 07:41
  • @NevilleNazerane Actually i want to create two tables because vendor can also login as a customer with same username.If i create it in one table then what will happen is.Assume vendor has entry in our database with username 1234 and users wants to create account in customer table and he is using same username i.e. 1234 so if i keep my both entries in same table then it won't allow to create a duplicate username.That's why i want two different table. – Firoz Rangrez Dec 18 '20 at 09:28
  • @Yinqiu Yeah sure i will look into that ,Thanks for replying . – Firoz Rangrez Dec 18 '20 at 09:28

2 Answers2

1

Look into extending the aspnet-identity models. I added my own fields to the identity tables and customized the solution - I need 9+ different roles etc. It's a lot of work, but I feel it was worth it in the end.

See this for more information : https://learn.microsoft.com/en-us/aspnet/core/security/authentication/customize-identity-model?view=aspnetcore-5.0

1

I think you should be able to kinda achieve something like this if you use "Azure AD B2C" as an online Login provider.

It is possible to create different login pages with different data that you gather. For example:

  • Customer: Name, Age, Address, etc...
  • Retailer: Company Name, Address, etc...

For the first 50000 logins/month it is completely free.

Some useful resources on how to get started are:

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459