es6
This commit is contained in:
parent
50c9aaa0c4
commit
63fbbcf110
3 changed files with 27 additions and 27 deletions
36
app.js
36
app.js
|
@ -1,19 +1,19 @@
|
|||
var express = require('express');
|
||||
var path = require('path');
|
||||
var favicon = require('serve-favicon');
|
||||
var logger = require('morgan');
|
||||
var cookieParser = require('cookie-parser');
|
||||
var bodyParser = require('body-parser');
|
||||
var sassMiddleware = require('node-sass-middleware');
|
||||
var subdomain = require('express-subdomain');
|
||||
import express from 'express';
|
||||
import path from 'path'
|
||||
import logger from "morgan";
|
||||
// import favicon from "serve-favicon";
|
||||
import cookieParser from "cookie-parser";
|
||||
import bodyParser from "body-parser";
|
||||
import sassMiddleware from "node-sass-middleware";
|
||||
|
||||
var index = require('./routes/index');
|
||||
var cufs = require('./routes/cufs');
|
||||
var uonetplus = require('./routes/uonetplus');
|
||||
var uonetplusOpiekun = require('./routes/uonetplus-opiekun');
|
||||
var uonetplusUzytkownik = require('./routes/uonetplus-uzytkownik');
|
||||
import subdomain from "express-subdomain";
|
||||
import index from "./routes/index";
|
||||
import cufs from "./routes/cufs";
|
||||
import uonetplus from "./routes/uonetplus";
|
||||
import uonetplusOpiekun from "./routes/uonetplus-opiekun";
|
||||
import uonetplusUzytkownik from "./routes/uonetplus-uzytkownik";
|
||||
|
||||
var app = express();
|
||||
const app = express();
|
||||
|
||||
// view engine setup
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
|
@ -33,7 +33,7 @@ app.use(sassMiddleware({
|
|||
}));
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
app.use((req, res, next) => {
|
||||
res.locals.uonetplusUrl = "http://" + req.get('host').replace("uonetplus-opiekun", "uonetplus");
|
||||
res.locals.mainHost = "http://" + req.get('host')
|
||||
.replace(/(cufs|uonetplus|uonetplus-opiekun|uonetplus-uzytkownik)\./, "");
|
||||
|
@ -47,14 +47,14 @@ app.use(subdomain('uonetplus-uzytkownik', uonetplusUzytkownik));
|
|||
app.use('/', index);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use(function(req, res, next) {
|
||||
var err = new Error('Not Found');
|
||||
app.use((req, res, next) => {
|
||||
const err = new Error('Not Found');
|
||||
err.status = 404;
|
||||
next(err);
|
||||
});
|
||||
|
||||
// error handler
|
||||
app.use(function(err, req, res, next) {
|
||||
app.use((err, req, res, next) => {
|
||||
// set locals, only providing error in development
|
||||
res.locals.message = err.message;
|
||||
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
var express = require('express');
|
||||
var fs = require('fs');
|
||||
var router = express.Router();
|
||||
var protocol = require('../utils/connection');
|
||||
const express = require('express');
|
||||
const fs = require('fs');
|
||||
const router = express.Router();
|
||||
const protocol = require('../utils/connection');
|
||||
|
||||
router.get("/", function(req, res) {
|
||||
router.get("/", (req, res) => {
|
||||
res.redirect("/Default/Account/LogOn");
|
||||
});
|
||||
|
||||
// GET login page
|
||||
router.get("/Default/Account/LogOn", function(req, res) {
|
||||
router.get("/Default/Account/LogOn", (req, res) => {
|
||||
res.render("login-form", { title: "Logowanie (Default)" });
|
||||
});
|
||||
|
||||
// POST login
|
||||
router.post("/Default/Account/LogOn", function(req, res) {
|
||||
router.post("/Default/Account/LogOn", (req, res) => {
|
||||
if ('admin' === req.body.LoginName && 'admin' === req.body.Password) {
|
||||
return res.redirect("/Default/FS/LS?" +
|
||||
"wa=wsignin1.0&" +
|
||||
|
@ -24,7 +24,7 @@ router.post("/Default/Account/LogOn", function(req, res) {
|
|||
res.render("login-form", { title: "Logowanie (Default)", message: "Zła nazwa użytkownika lub hasło" });
|
||||
});
|
||||
|
||||
router.get("/Default/FS/LS", function (req, res) {
|
||||
router.get("/Default/FS/LS", (req, res) => {
|
||||
res.render("login-cert", {
|
||||
cert: fs.readFileSync("public/cert.xml", "utf8"),
|
||||
uonetplusOpiekun: protocol(req) + "://" + req.get('host').replace("cufs.", "uonetplus.")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
function getProtocol(req) {
|
||||
var proto = req.connection.encrypted ? 'https' : 'http';
|
||||
let proto = req.connection.encrypted ? 'https' : 'http';
|
||||
// only do this if you trust the proxy
|
||||
proto = req.headers['x-forwarded-proto'] || proto;
|
||||
return proto.split(/\s*,\s*/)[0];
|
||||
|
|
Loading…
Reference in a new issue