What's the best way to upgrade my previous CustomRoleProvider to the new providers in Asp.Net MVC 5. I just implemented those methods and rolled out my own tables (because it's a multiple database web application).
What would be the easiest and fastest way to upgrade my authentication?
My previous web.config
<roleManager enabled="true" defaultProvider="MyCustomRoleProvider" cacheRolesInCookie="true" createPersistentCookie="true">
<providers>
<clear />
<add name="MyCustomRoleProvider" type="FacturatieMVCv2.Web.Core.MyCustomRoleProvider" />
</providers>
</roleManager>
And my RoleProvider
Imports FacturatieMVCv2.Service
Imports FacturatieMVCv2.Domain.Common
Imports System.Web
Imports FacturatieMVCv2.Web.Core
Public Class MyCustomRoleProvider
Inherits System.Web.Security.RoleProvider
Dim _userService As Master.UserService
Public Sub New(ByVal UserService As Master.IUserService)
_userService = UserService
End Sub
Public Sub New()
End Sub
Public Overrides Sub AddUsersToRoles(usernames() As String, roleNames() As String)
End Sub
Public Overrides Property ApplicationName As String
Get
Return My.Application.Info.AssemblyName
End Get
Set(value As String)
End Set
End Property
Public Overrides Sub CreateRole(roleName As String)
Throw New NotImplementedException("UsesBitWiseOperations, change the ENUM Field")
End Sub
Public Overrides Function DeleteRole(roleName As String, throwOnPopulatedRole As Boolean) As Boolean
Throw New NotImplementedException("UsesBitWiseOperations, change the ENUM Field")
End Function
Public Overrides Function FindUsersInRole(roleName As String, usernameToMatch As String) As String()
Return _userService.FindUsersInRole(roleName, usernameToMatch).Select(Function(el) el.UserName)
End Function
Public Overrides Function GetAllRoles() As String()
Return _userService.GetAllRoles
End Function
Public Overrides Function GetRolesForUser(username As String) As String()
Return _userService.GetRolesForUser(username)
End Function
Public Overrides Function GetUsersInRole(roleName As String) As String()
Return _userService.GetUsersInRole(roleName).Select(Function(el) el.UserName)
End Function
Public Overrides Function IsUserInRole(username As String, roleName As String) As Boolean
Return _userService.IsUserInRole(username, roleName)
End Function
Public Overrides Sub RemoveUsersFromRoles(usernames() As String, roleNames() As String)
_userService.RemoveUsersFromRoles(usernames, roleNames)
End Sub
Public Overrides Function RoleExists(roleName As String) As Boolean
Return _userService.RoleExists(roleName)
End Function
End Class