Create custom login system with FormsAuthentication and more in ASP.NET MVC 3 Razor?

1.7k Views Asked by At

Sorry for the big title.

So I've been doing some research for making login systems. I've already made my own, but discovered a more secure way to do it. As far as I know, the four basic components of this login system are:

  • FormsAuthentication
  • MembershipProvider
  • RoleProvider
  • Principal

I have this as my basic user model:

public class User
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Password { get; set; }
    public string PictureUrl { get; set; }
    public string Role { get; set; }
    public string AccessToken { get; set; }
}

This is just for retaining the data from the database.

I still want to use this model with the components listed above.

Does anyone know a good and thorough tutorial that explains how to create a custom login system using the above components in MVC 3 Razor?

Thanks in advance.

2

There are 2 best solutions below

0
StanK On BEST ANSWER

You can build a custom 'login system' by implementing a custom version of MembershipProvider and RoleProvider that uses your own database. Then you can re-use all the rest of the built in authentication and authorization stuff.

MSDN has some details on how to build a MembershipProvider here and details on a custom RoleProvider here. Samples implementations are included.

0
Anas On

You can use this open source project :

https://github.com/TroyGoode/MembershipStarterKit