Add mobile devices register to new student module

This commit is contained in:
Mikołaj Pich 2019-02-05 20:40:30 +01:00
parent 4b9b536db8
commit 373abf228e
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
4 changed files with 57 additions and 4 deletions

33
package-lock.json generated
View file

@ -872,6 +872,16 @@
"integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=",
"dev": true
},
"csrf": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/csrf/-/csrf-3.0.6.tgz",
"integrity": "sha1-thEg3c7q/JHnbtUxO7XAsmZ7cQo=",
"requires": {
"rndm": "1.2.0",
"tsscmp": "1.0.5",
"uid-safe": "2.1.4"
}
},
"currently-unhandled": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz",
@ -3539,6 +3549,11 @@
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
},
"random-bytes": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz",
"integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs="
},
"range-parser": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
@ -3869,6 +3884,11 @@
"glob": "^7.0.5"
}
},
"rndm": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/rndm/-/rndm-1.2.0.tgz",
"integrity": "sha1-8z/pz7Urv9UgqhgyO8ZdsRCht2w="
},
"safe-buffer": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
@ -4459,6 +4479,11 @@
}
}
},
"tsscmp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.5.tgz",
"integrity": "sha1-fcSjOvcVgatDN9qR2FylQn69mpc="
},
"tunnel-agent": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
@ -4546,6 +4571,14 @@
"integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=",
"optional": true
},
"uid-safe": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.4.tgz",
"integrity": "sha1-Otbzg2jG1MjHXsF2I/t5qh0HHYE=",
"requires": {
"random-bytes": "~1.0.0"
}
},
"undefsafe": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.2.tgz",

View file

@ -10,6 +10,7 @@
"dependencies": {
"body-parser": "~1.18.3",
"cookie-parser": "~1.4.3",
"csrf": "^3.0.6",
"date-fns": "^2.0.0-alpha.24",
"debug": "^4.1.1",
"express": "~4.16.4",

View file

@ -3,7 +3,7 @@ const protocol = require('../../utils/connection');
const api = require("../../utils/api");
router.all("/Certyfikat", (req, res) => {
let base = protocol(req) + "://" + req.get('host');
const base = protocol(req) + "://" + req.get('host');
// key gen
// keytool -genkeypair -keystore myKeystore.p12 -storetype PKCS12 -storepass 012345678901234567890123456789AB -alias LoginCert -keyalg RSA -keysize 2048 -sigalg SHA1WithRSA -validity 99999 -dname "CN=Wulkanowy, OU=Wulkanowy, O=Wulkanowy, L=Jaroslaw, ST=podkarpackie, C=WLKNW" -ext san=dns:fakelog.cf,dns:localhost,ip:127.0.0.1

View file

@ -3,6 +3,7 @@ const router = express.Router();
const protocol = require('../utils/connection');
const dictMap = require('../utils/dictMap');
const converter = require('../utils/converter');
const Tokens = require('csrf');
const {format, fromUnixTime, getYear, addYears, addMonths, addDays, differenceInDays, toDate} = require('date-fns');
router.get("/", (req, res) => {
@ -341,8 +342,26 @@ router.all("/Pomoc.mvc/Get", (req, res) => {
});
router.all("/RejestracjaUrzadzeniaToken.mvc/Get", (req, res) => {
const student = require('../../data/api/ListaUczniow')[1];
const base = protocol(req) + "://" + req.get('host');
const token = new Tokens({secretLength: 97, saltLength: 4});
const secret = token.secretSync();
res.json({
"data": {},
"data": {
"TokenId": 423,
"TokenKey": "FK100000",
"CustomerGroup": "Default",
"CustomerSymbol": student.JednostkaSprawozdawczaSymbol,
"QrCodeContent": `CERT#${base}/Default/mobile-api#FK100000#ENDCERT`,
"QrCodeContentEncoded": "xxx", // TODO: create and use qr encrypt
"QrCodeImage": "<img src=\"data:image/png;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==\" alt=\"Kod QR\" title=\"Kod QR\" height=\"400\" width=\"400\" />",
"ImageSize": 400,
"IdLogin": student.UzytkownikLoginId,
"LoginValue": student.UzytkownikLogin,
"PIN": "999999",
"AntiForgeryAppGuid": secret,
"AntiForgeryToken": token.create(secret)
},
"success": true
});
});
@ -356,7 +375,7 @@ router.all("/RejestracjaUrzadzeniaToken.mvc/Delete", (req, res) => {
router.all("/RejestracjaUrzadzeniaTokenCertyfikat.mvc/Get", (req, res) => {
res.json({
"data": {},
"data": true,
"success": true
});
});
@ -497,7 +516,7 @@ router.all("/ZarejestrowaneUrzadzenia.mvc/Get", (req, res) => {
router.all("/ZarejestrowaneUrzadzenia.mvc/Delete", (req, res) => {
res.json({
"data": {},
"data": null,
"success": true
});
});