public bool TokenTienePermisos(string token, int idUsuario)
        {
            bool resultado = false;

            AdministradorDeSesiones.AdministradorDeSesionesClient cliente = new AdministradorDeSesiones.AdministradorDeSesionesClient(ServicioDeSesiones);
            SesionPeticion sesionPeticion = new SesionPeticion()
            {
                IdSesion = token
            };
            ExistenciaDeSesion existenciaDeSesion = new ExistenciaDeSesion();

            try
            {
                existenciaDeSesion = cliente.ExisteSesion(sesionPeticion);
            }
            catch (System.Net.Http.HttpRequestException e)
            {
                throw new AccesoAServicioException("Sesiones", e);
            }
            catch (Grpc.Core.RpcException e)
            {
                throw new AccesoAServicioException("Sesiones", e);
            }
            if (existenciaDeSesion.IdUsuario == idUsuario)
            {
                resultado = true;
            }
            return(resultado);
        }
        public bool ValidarSesion(string token)
        {
            bool resultado = false;

            AdministradorDeSesiones.AdministradorDeSesionesClient cliente = new AdministradorDeSesiones.AdministradorDeSesionesClient(ServicioDeSesiones);
            SesionPeticion sesionPeticion = new SesionPeticion()
            {
                IdSesion = token
            };
            ExistenciaDeSesion existenciaDeSesion = new ExistenciaDeSesion();

            try
            {
                existenciaDeSesion = cliente.ExisteSesion(sesionPeticion);
            }
            catch (System.Net.Http.HttpRequestException e)
            {
                throw new AccesoAServicioException("Sesiones", e);
            }
            catch (Grpc.Core.RpcException e)
            {
                throw new AccesoAServicioException("Sesiones", e);
            }
            resultado = existenciaDeSesion.ExistenciaDeSesion_;
            return(resultado);
        }
Example #3
0
        public override Task <ExistenciaDeSesion> ExisteSesion(SesionPeticion request, ServerCallContext context)
        {
            ExistenciaDeSesion existenciaDeSesion = new ExistenciaDeSesion()
            {
                ExistenciaDeSesion_ = ControladorDeSesiones.SesionExiste(request.IdSesion)
            };

            if (existenciaDeSesion.ExistenciaDeSesion_)
            {
                existenciaDeSesion.IdUsuario = ControladorDeSesiones.ObtenerIdUsuarioPorIdSesion(request.IdSesion);
            }
            else
            {
                existenciaDeSesion.IdUsuario = 0;
            }

            return(Task.FromResult(existenciaDeSesion));
        }