Пример #1
0
        /// <summary>
        /// Obtem a Matrícula e o Nome Completo do Usuário Logado
        /// </summary>
        /// <returns></returns>
        public static string ObterMatriculaComNomeCompleto()
        {
            string matricula    = ClaimsHelper.ObterClaim(Claims.Matricula)?.Value;
            string nomeCompleto = ClaimsHelper.ObterClaim(Claims.NomeCompleto)?.Value;

            return($"{matricula} - {nomeCompleto}");
        }
Пример #2
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return(false);
            }

            if (!ValidaAmbiente(httpContext))
            {
                return(false);
            }

            var isAuthorized = base.AuthorizeCore(httpContext);

            if (!isAuthorized)
            {
                string    usuario   = ClaimsHelper.ObterClaim(Claims.Matricula).Value;
                Exception exception = new HttpException(401, $"Usuário {HttpContext.Current.User.Identity.Name} - {usuario} não autorizado para acessar a página: {HttpContext.Current.Request.Url.AbsoluteUri}");
                ErrorSignal.FromCurrentContext().Raise(exception, HttpContext.Current);
            }



            return(isAuthorized);
        }
        public static MvcHtmlString ObterFotoFuncionario(this HtmlHelper htmlHelper, string urlWebSite)
        {
            var    html         = new StringBuilder();
            int    matricula    = ClaimsHelper.ObterClaim(Claims.Matricula).Value.ToInt();
            string primeiroNome = ClaimsHelper.ObterClaim(Claims.PrimeiroNome).Value;

            byte[] foto = null;

            var appFuncionario = SimpleInjectorInitializerFactory.GetInstance <IFotoFuncionarioApp>();

            try
            {
                foto = appFuncionario.ObterFotoFuncionario(matricula);
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex, HttpContext.Current);
            }

            html.AppendLine("<span href=\"#\">" + primeiroNome + "</span>");

            if (foto != null)
            {
                html.AppendLine("<img id='imgFotoServidor' src='data:image/png; base64," + Convert.ToBase64String(foto) + "' class='rounded-circle user-image' alt='Foto' />");
            }
            else
            {
                html.AppendLine("<img id='imgFotoServidor' src='" + urlWebSite + "Content/Images/PersonPlaceholder.png' class='rounded-circle user-image' alt='Foto' />");
            }

            html.AppendLine("<input type='hidden' value='" + matricula + "' id='hdnIdentificaUsuario' />");

            return(MvcHtmlString.Create(html.ToString()));
        }
        public static MvcHtmlString ObterUnidadeFuncionario(this HtmlHelper htmlHelper)
        {
            var html      = new StringBuilder();
            int matricula = ClaimsHelper.ObterClaim(Claims.Matricula).Value.ToInt();

            string unidade = string.Empty;

            try
            {
                unidade = "Definir a implementação da unidade conforme a regra do sistema";
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex, HttpContext.Current);
            }

            if (!string.IsNullOrEmpty(unidade))
            {
                html.AppendLine(unidade);
            }

            return(MvcHtmlString.Create(html.ToString()));
        }
Пример #5
0
 /// <summary>
 /// Retorna o nome completo do usuário logado
 /// </summary>
 /// <returns></returns>
 public static string ObterNomeCompleto()
 {
     return(ClaimsHelper.ObterClaim(Claims.NomeCompleto)?.Value);
 }
Пример #6
0
        public static int ObterMatricula()
        {
            string matricula = ClaimsHelper.ObterClaim(Claims.Matricula)?.Value;

            return(matricula.ToInt());
        }
Пример #7
0
 /// <summary>
 /// Obtem a Matrícula do Usuário Logado
 /// </summary>
 /// <param name="claim"></param>
 /// <returns></returns>
 public static string ObterValorClaim(string claim)
 {
     return(ClaimsHelper.ObterClaim(claim)?.Value);
 }