Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to apply custom validations into role providers in ASP.NET MVC5 with ASP.Net Identity?

$
0
0

I have modified UserRole entity with new properties. I need to validate user login and generate role based menu according to those properties.

public class ApplicationUserRole : IdentityUserRole
{
    /// <summary>
    /// Initializes a new instance of the <see cref="ApplicationUserRole"/> class.
    /// </summary>
    public ApplicationUserRole()
        : base()
    {
        this.ValidFrom = DateTime.Now;
        this.ValidTo = DateTime.Now;

    }

    /// <summary>
    /// Gets or sets the valid from.
    /// </summary>
    /// <value>The valid from.</value>
    public virtual DateTime? ValidFrom { get; set; }

    /// <summary>
    /// Gets or sets the valid to.
    /// </summary>
    /// <value>The valid to.</value>
    public virtual DateTime? ValidTo { get; set; }

 }

if the login date not exists on the valid date range need to show user login expired message and if there is assigned multiple roles and expired one role need to hide those menu items on menu list.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>