mirror of
https://github.com/guilhermewerner/gerencia-projetos
synced 2025-06-15 22:45:09 +00:00
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GerenciaProjetos.Filters
|
|
{
|
|
public class LoginFilterAttribute : Attribute, IActionFilter
|
|
{
|
|
public bool Restrito { get; set; }
|
|
|
|
public void OnActionExecuted(ActionExecutedContext context)
|
|
{
|
|
int? IdUsuario = context.HttpContext.Session.GetInt32("Id");
|
|
|
|
if (IdUsuario == null)
|
|
{
|
|
context.Result = new RedirectToRouteResult(new { controller = "Home", action = "Index" });
|
|
}
|
|
else if (context.HttpContext.Session.GetInt32("EAdmin") != 1 && Restrito)
|
|
{
|
|
context.Result = new RedirectToRouteResult(new
|
|
{
|
|
controller = "Dashboard",
|
|
action = "Index"
|
|
});
|
|
}
|
|
}
|
|
|
|
public void OnActionExecuting(ActionExecutingContext context)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|