/// <summary>
/// Override onAuthorization filter is use for authorization
use request.
/// </summary>
protected override void OnAuthorization(AuthorizationContext filterContext)
{
AuthorizationManager authorizationManager = new AuthorizationManager();
string FilePath = Convert.ToString(filterContext.HttpContext.Request.FilePath);
if (!authorizationManager.IsAuthorized(_userSession,
FilePath))
{
RedirectToControllers(ControllerHelper.ACCOUNT, ControllerHelper.Action.ACCOUNT_LOGIN);
}
}
/// <summary>
/// This method is used for check the current request is authorized or not.
/// </summary>
#region Authorization public methods
public bool IsAuthorized(UserSession sessions, string url)
{
bool IsIsAuthorize = false;
if (sessions != null)
{
if (sessions.UserType != null && sessions.UserType != "")
{
IsIsAuthorize = new Authorizations().IsAuthorized(sessions,
url);
}
}
return IsIsAuthorize;
#endregion
/// <summary>
/// This method is used to get the authorized URL list with help of current user-type.
/// and call the the authorization repository Authorized method.
/// and call the the authorization repository Authorized method.
/// </summary>
public bool IsAuthorized(UserSession userSession, string url)
{
return new AuthorizedRepository().Authorized(userSession.UserType, url);
}
/// <summary>
/// This method is used to return the authorized URLs.
/// </summary>
public bool Authorized(string UserType, string url)
{
bool authorized = false;
AuthorizedURL Urls = base.Context.AuthorizedURLs.Where(x => x.UserType ==
UserType && x.URL == url && x.IsActive == true).SingleOrDefault();
if (Urls != null)
{
authorized = true;
}
return authorized;
}