Skip to content

Commit

Permalink
mejor modulo de cifrado
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael committed Jun 12, 2018
1 parent 9c33f3f commit 604a0ea
Show file tree
Hide file tree
Showing 294 changed files with 769 additions and 521 deletions.
12 changes: 10 additions & 2 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@
/**
Inserta en la base de datos un usuario administrador
*/
var bcrypt = require('bcrypt'); // Permite cifrar la contraseña
var crypto = require('crypto'); // Permite cifrar la contraseña
// Archivo local que contiene la información de la cuenta de administrador
var appConfig = require('./src/conf').conf["session"];
// El manejador de la base de datos.
var dbManager = require('./src/controllers/database');

/* Cifra las contraseñas */
function encrypt(text){
var cipher = crypto.createCipher(appConfig["algorithm"], appConfig["secret"])
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}

// Se cifra la contraseña.
var hash = bcrypt.hashSync(appConfig["password"], appConfig["saltRounds"]);
var hash = encrypt(appConfig["password"]);

// Busca en la base de datos si el usuario ya existe,
// Si no existe entonces lo inserta en la collección, sino entonces
Expand Down
2 changes: 1 addition & 1 deletion juegos/elGlobo/data/info.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"instrucciones": "El paciente tendrá que soplar para que el globo no explote al tocar un pico."
"instrucciones": "El paciente tendrá que soplar para obtener la mayor cantidad de monedas."
}
3 changes: 3 additions & 0 deletions juegos/puntosVista2/data/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"instrucciones": "En esta sección se mostrará una lista de opciones con los 8 puntos de vista de cada cámara. El problema consiste en descifrar cuál es la imágen que corresponde a la cámara seleccionada."
}
41 changes: 41 additions & 0 deletions juegos/puntosVista2/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Puntos de vista</title>

<style type="text/css">
img {
max-width: 100%;
max-height: 100%;
}
</style>
<link rel="stylesheet" type="text/css" href="./public/css/extra_fa.css">

<% include ../../src/views/layouts/header %>
<script src="/public/common/js/d3/d3.min.js"></script>
<script src="/public/common/js/react.js"></script>
<script src="/public/common/js/react-dom.js"></script>
<!-- <script src="/public/common/js/browser.js"></script> -->
</head>

<body class="bg-light text-dark">
<% include ../../src/views/layouts/nav %>

<div class="container">
<div class="row my-3">
<div class="col-md-12">
<h3><b class="text-accent">Paciente actual: </b><span id="paciente_actual"></span></h3>
</div>
</div>

<div class="row">
<div class="col-12">
<div id="main"></div>
</div>
</div>
</div>

<script type="text/javascript" src="./public/js/Main.min.js"></script>
</body>

</html>
5 changes: 5 additions & 0 deletions juegos/puntosVista2/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"nombre": "Puntos de vista 2",
"img": "thumbnail.jpg",
"categorias": ["O"]
}
31 changes: 31 additions & 0 deletions juegos/puntosVista2/public/js/Ejercicio.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Img from '../../../../public/common/js/juegos/compiled/Img.jsx';

class Ejercicio extends React.Component{
render(){
return(<div className="row">
<div className="col-6">
<Img url="./../../../../public/common/img/puntosVista/1/1/0.png" />
</div>

<div className="col-6">
<svg viewBox="0 0 100 60">
<image y="4"
width="100" height="50"
href="./../../../../public/common/img/puntosVista/1/1/aereo.png" />
<circle fill="red" cx={23} cy={4} r={2} />
<circle fill="red" cx={50} cy={4} r={2} />
<circle fill="red" cx={77} cy={4} r={2} />

<circle fill="red" cx={23} cy={29} r={2} />
<circle fill="red" cx={77} cy={29} r={2} />

<circle fill="red" cx={23} cy={54} r={2} />
<circle fill="red" cx={50} cy={54} r={2} />
<circle fill="red" cx={77} cy={54} r={2} />
</svg>
</div>
</div>);
}
}

export default Ejercicio;
114 changes: 114 additions & 0 deletions juegos/puntosVista2/public/js/Main.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import Bloque from '../../../../public/common/js/juegos/compiled/Bloque.jsx';
import Instrucciones from '../../../../public/common/js/juegos/compiled/Instrucciones.jsx';
import Nivel from '../../../../public/common/js/juegos/compiled/Nivel.jsx';
import Fin from '../../../../public/common/js/juegos/compiled/Fin.jsx';
import Ejercicio from './Ejercicio.jsx';

class Main extends React.Component {
constructor(props) {
super(props);
this.juego = "puntosVista2";

this.state = {
inicio: true,
fin: false,
seleccionNivel: false,
porcentaje: null,
}

this.iniciar = this.iniciar.bind(this);
this.seleccionarNivel = this.seleccionarNivel.bind(this);
this.terminar = this.terminar.bind(this);
this.reiniciar = this.reiniciar.bind(this);
}

iniciar() {
this.setState({
seleccionNivel: false,
inicio: true,
});
}

reiniciar(){
this.setState({
inicio: false,
fin: false,
seleccionNivel: true,
porcentaje: null
});
}

terminar(porcentaje) {
this.setState({
fin: true,
porcentaje: porcentaje
});
}

seleccionarNivel(nivel) {
this.nivel = nivel;
this.setState({
seleccionNivel: false
});
}

render() {
if (this.state.seleccionNivel) {
return (
<Bloque nombre={this.props.nombre}>
<Nivel seleccionar={this.seleccionarNivel} />
</Bloque>
);
} else if (this.state.fin) {
return(
<Bloque nombre={this.props.nombre}>
<Fin
juego={this.juego}
fechaInicio={this.fechaInicio}
nivel={this.nivel}
paciente={this.props.paciente}
reiniciar={this.reiniciar}
porcentaje={this.state.porcentaje} />
</Bloque>
);
} else if (this.state.inicio) {
return (
<Bloque nombre={this.props.nombre}>
<Ejercicio nivel={this.nivel} terminar={this.terminar}/>
</Bloque>
);
} else {
return (
<Bloque nombre={this.props.nombre}>
<Instrucciones
iniciar={this.iniciar}
instrucciones={this.props.instrucciones} />
</Bloque>
);
}
}
}

function getInfo(callback) {
d3.json("./data/info.json", function(error, instrucciones) {
d3.json("./meta.json", function(error, nombre) {
Consulta.get('/paciente/actual/', function(data) {
if (data["id"] != null) {
mostrarPerfil(data);
callback(data["id"],nombre["nombre"], instrucciones["instrucciones"]);
} else {
toastr("No has seleccionado un paciente");
}
});
});
});
}

$(document).ready(function(){
getInfo(function(paciente, nombre, instrucciones, datos) {
ReactDOM.render(<Main
paciente={paciente}
nombre={nombre}
instrucciones={instrucciones}/>, document.getElementById('main'));
})
});
Loading

0 comments on commit 604a0ea

Please sign in to comment.