Commit f42e9049 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

add compiled codes

parent 6b3fefa5
"use strict";var _process$env$NODE_ENV,_express=_interopRequireDefault(require("express")),_path=_interopRequireDefault(require("path")),_passport=_interopRequireDefault(require("passport")),_morgan=_interopRequireDefault(require("morgan")),_cookieParser=_interopRequireDefault(require("cookie-parser")),_bodyParser=_interopRequireDefault(require("body-parser")),_expressSession=_interopRequireDefault(require("express-session")),_expressFlash=_interopRequireDefault(require("express-flash-2")),_expressFileupload=_interopRequireDefault(require("express-fileupload")),_helmet=_interopRequireDefault(require("helmet")),_compression=_interopRequireDefault(require("compression")),_methodOverride=_interopRequireDefault(require("method-override"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var env=null!==(_process$env$NODE_ENV=process.env.NODE_ENV)&&void 0!==_process$env$NODE_ENV?_process$env$NODE_ENV:"testing",config=require("./config/config")[env],lang="DE",app=(0,_express["default"])();// enable files upload
// caching disabled for every route
// NOTE: Works in Firefox and Opera. Does not work in Edge
// Handle 404
// Handle 500 - any server error
app.set("port",config.app.port),app.set("views",_path["default"].join(_path["default"].join(__dirname,"/views"))),app.set("view engine","pug"),app.use((0,_expressFileupload["default"])({createParentPath:!0,limits:{fileSize:1e6// 1 MB max. file size
}})),app.use((0,_methodOverride["default"])("_method")),app.use(_helmet["default"].contentSecurityPolicy({useDefaults:!0,directives:{"font-src":["'self'","https://use.fontawesome.com"],"img-src":["'self'","https://transfer.hft-stuttgart.de"],"script-src":["'self'","https://code.jquery.com/jquery-3.3.1.min.js","https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js","https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js","https://unpkg.com/bootstrap-show-password@1.2.1/dist/bootstrap-show-password.min.js"],"style-src":["'self'","https://use.fontawesome.com/releases/v5.8.2/css/all.css"],"frame-src":["'self'"]},reportOnly:!0})),app.use((0,_compression["default"])()),app.use((0,_morgan["default"])("combined")),app.use((0,_cookieParser["default"])(config.app.sessionSecret)),app.use(_bodyParser["default"].json()),app.use(_bodyParser["default"].urlencoded({extended:!1})),app.use(_express["default"]["static"](_path["default"].join(__dirname,"public"))),app.use(function(a,b,c){c()}),app.use((0,_expressSession["default"])({resave:!0,saveUninitialized:!0,secret:config.app.sessionSecret})),app.use((0,_expressFlash["default"])()),app.use(_passport["default"].initialize()),app.use(_passport["default"].session()),app.use(function(a,b,c){b.set("Cache-Control","no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0"),c()}),require("./routes/public")(app,config,lang),require("./routes/account")(app,config,_passport["default"],lang),app.use(function(a,b){b.status(404).render(lang+"/404")}),app.use(function(a,b,c){console.error(a.stack),c.status(500).render(lang+"/500",{error:a})}),app.listen(app.get("port"),function(){console.log("Express server listening on port "+app.get("port"))});
\ No newline at end of file
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Project=void 0;function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}var Project=/*#__PURE__*/function(){function a(b,c,d,e,f,g){_classCallCheck(this,a),this.ownerGitlabId=b,this.name=c,this.desc=d,this.id=e,this.logo=f,this.path=g}// getter
return _createClass(a,[{key:"getOwnerGitlabId",value:function getOwnerGitlabId(){return this.ownerGitlabId}},{key:"getId",value:function getId(){return this.id}},{key:"getName",value:function getName(){return this.name}},{key:"getDesc",value:function getDesc(){return this.desc}},{key:"getLogo",value:function getLogo(){return this.logo}},{key:"getPath",value:function getPath(){return this.path}// setter
},{key:"setOwnerGitlabId",value:function setOwnerGitlabId(a){this.ownerGitlabId=a}},{key:"setId",value:function setId(a){this.id=a}},{key:"setName",value:function setName(a){this.name=a}},{key:"setDesc",value:function setDesc(a){this.desc=a}},{key:"setLogo",value:function setLogo(a){this.logo=a}},{key:"setPath",value:function setPath(a){this.path=a}}]),a}();exports.Project=Project;
\ No newline at end of file
"use strict";var _project=require("./project");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Repo=void 0;function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&("object"===_typeof(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}var Repo=/*#__PURE__*/function(a){function b(a,d,e,f,g,h){return _classCallCheck(this,b),c.call(this,a,d,e,f,g,h)}_inherits(b,a);var c=_createSuper(b);return _createClass(b)}(_project.Project);exports.Repo=Repo;
\ No newline at end of file
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.User=void 0;function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}var User=/*#__PURE__*/function(){// should be enum
// should be enum
// 1 or 0
// 1 or 0 - // should be boolean
function a(b,c,d,e,f,g,h,i,j,k,l,m){_classCallCheck(this,a),this.id=b,this.email=c,this.salutation=d,this.title=e,this.firstName=f,this.lastName=g,this.industry=h,this.organisation=i,this.speciality=j,this.isM4labIdp=k,this.verificationStatus=l,this.gitlabUserId=m}// getter
return _createClass(a,[{key:"getId",value:function getId(){return this.id}},{key:"getEmail",value:function getEmail(){return this.email}},{key:"getFullName",value:function getFullName(){return this.firstName+" "+this.lastName}},{key:"getIdpStatus",value:function getIdpStatus(){return this.isM4labIdp}},{key:"getVerificationStatus",value:function getVerificationStatus(){return this.verificationStatus}},{key:"getGitlabUserId",value:function getGitlabUserId(){return this.gitlabUserId}// setter
},{key:"setEmail",value:function setEmail(a){this.email=a}},{key:"setSalutation",value:function setSalutation(a){this.salutation=a}},{key:"setTitle",value:function setTitle(a){this.title=a}},{key:"setFirstName",value:function setFirstName(a){this.firstName=a}},{key:"setLastName",value:function setLastName(a){this.lastName=a}},{key:"setIndustry",value:function setIndustry(a){this.industry=a}},{key:"setOrganisation",value:function setOrganisation(a){this.organisation=a}},{key:"setSpeciality",value:function setSpeciality(a){this.speciality=a}},{key:"setM4lab_idp",value:function setM4lab_idp(a){this.isM4labIdp=a}},{key:"setVerificationStatus",value:function setVerificationStatus(a){this.verificationStatus=a}},{key:"setGitlabUserId",value:function setGitlabUserId(a){this.gitlabUserId=a}},{key:"updateProfile",value:function updateProfile(a,b,c,d,e,f,g,h){this.salutation=a,this.title=b,this.firstName=c,this.lastName=d,this.email=e,this.organisation=f,this.industry=g,this.speciality=h}}]),a}();exports.User=User;
\ No newline at end of file
"use strict";var _project=require("./project");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Website=void 0;function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&("object"===_typeof(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}var Website=/*#__PURE__*/function(a){function b(a,d,e,f,g,h){return _classCallCheck(this,b),c.call(this,a,d,e,f,g,h)}_inherits(b,a);var c=_createSuper(b);return _createClass(b)}(_project.Project);exports.Website=Website;
\ No newline at end of file
"use strict";var _process$env$PORT,_process$env$SAML_PAT,_process$env$PORT2,_process$env$SAML_PAT2,_process$env$SAML_ENT;Object.defineProperty(exports,"__esModule",{value:!0});module.exports={development:{app:{name:"User Account Management",port:null!==(_process$env$PORT=process.env.PORT)&&void 0!==_process$env$PORT?_process$env$PORT:9989,host:"http://localhost:9989",sessionSecret:"thisisasecret"},passport:{strategy:"saml",saml:{path:null!==(_process$env$SAML_PAT=process.env.SAML_PATH)&&void 0!==_process$env$SAML_PAT?_process$env$SAML_PAT:"/saml/SSO",entryPoint:process.env.SAML_ENTRY_POINT||"saml entry point",issuer:"SAML issuer",logoutUrl:"SAML logout URL"}},database:{host:"localhost",// DB host
user:"dbuser",// DB username
password:"dbpass",// DB password
port:3306,// MySQL port
dbUser:"userdb",// User DB
host_project:"localhost",// DB host project db
dbProject:"projectdb"// Project DB
},mailer:{host:"mailhost",// hostname
secureConnection:!1,// TLS requires secureConnection to be false
port:587,// port for secure SMTP
TLS:!0,authUser:"mailuser",authPass:"mailpass",tlsCiphers:"SSLv3",from:"mailfrom"},gitlab:{token_readWriteProjects:"token-goes-here"}},testing:{app:{name:"User Account Management",port:null!==(_process$env$PORT2=process.env.PORT)&&void 0!==_process$env$PORT2?_process$env$PORT2:9989,host:"https://m4lab.hft-stuttgart.de/account",sessionSecret:"thisisasecret"},passport:{strategy:"saml",saml:{path:null!==(_process$env$SAML_PAT2=process.env.SAML_PATH)&&void 0!==_process$env$SAML_PAT2?_process$env$SAML_PAT2:"/saml/SSO",entryPoint:null!==(_process$env$SAML_ENT=process.env.SAML_ENTRY_POINT)&&void 0!==_process$env$SAML_ENT?_process$env$SAML_ENT:"saml entry point",issuer:"SAML issuer",// testing metadata
logoutUrl:"SAML logout URL"}},database:{host:"dbhost",// DB host
user:"dbuser",// DB username
password:"dbpass",// DB password
port:3306,// MySQL port
dbUser:"userdb",// User DB
host_project:"dbhost",// DB host project db
dbProject:"projectdb"// Project DB
},mailer:{host:"mailhost",// hostname
secureConnection:!1,// TLS requires secureConnection to be false
port:587,// port for secure SMTP
TLS:!0,authUser:"mailuser",authPass:"mailpass",tlsCiphers:"SSLv3",from:"mailfrom"},gitlab:{token_readWriteProjects:"token-goes-here"}}};
\ No newline at end of file
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.miscConst=void 0;var miscConst={mailSignature:"Mit den besten Gr\xFC\xDFen,<br/>das Transferportal-Team der HFT Stuttgart<br/><br/>Transferportal der Hochschule f\xFCr Technik Stuttgart<br/>Schellingstr. 24 70174 Stuttgart<br/>m4lab@hft-stuttgart.de<br/><a mailConsthref=\"https://transfer.hft-stuttgart.de\">https://transfer.hft-stuttgart.de</a><br/><a href=\"http://www.hft-stuttgart.de/Aktuell/\"><img border=\"0\" alt=\"HFT\" src=\"https://m4lab.hft-stuttgart.de/img/signature/hft_logo.png\" width=\"30\" height=\"30\"></a> &nbsp;<a href=\"http://www.facebook.com/hftstuttgart\"><img border=\"0\" alt=\"Facebook\" src=\"https://m4lab.hft-stuttgart.de/img/signature/fb_bw.png\" width=\"30\" height=\"30\"></a> &nbsp;<a href=\"https://www.instagram.com/hft_stuttgart/\"><img border=\"0\" alt=\"Instagram\" src=\"https://m4lab.hft-stuttgart.de/img/signature/instagram_bw.png\" width=\"30\" height=\"30\"></a> &nbsp;<a href=\"https://twitter.com/hft_presse\"><img border=\"0\" alt=\"Twitter\" src=\"https://m4lab.hft-stuttgart.de/img/signature/twitter_bw.png\" width=\"30\" height=\"30\"></a> &nbsp;<a href=\"https://www.youtube.com/channel/UCi0_JfF2qMZbOhOnNH5PyHA\"><img border=\"0\" alt=\"Youtube\" src=\"https://m4lab.hft-stuttgart.de/img/signature/youtube_bw.png\" width=\"30\" height=\"30\"></a> &nbsp;<a href=\"http://www.hft-stuttgart.de/Aktuell/Presse-Marketing/SocialMedia/Snapcode HFT_Stuttgart.jpg/photo_view\"><img border=\"0\" alt=\"Snapchat\" src=\"https://m4lab.hft-stuttgart.de/img/signature/snapchat_bw.png\" width=\"30\" height=\"30\"></a><br/><img border=\"0\" src=\"https://m4lab.hft-stuttgart.de/img/signature/inno_bw.png\" width=\"150\" height=\"100\">",updatePasswordMailSubject:"Ihr Passwort f\xFCr das Transferportal wurde gespeichert.",updatePasswordMailContent:"<div>Lieber Nutzer,<br/><br/>Ihr Passwort wurde erfolgreich ge\xE4ndert.<br/><br/></div>"};exports.miscConst=miscConst;
\ No newline at end of file
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.dbConnection=void 0;var _process$env$NODE_ENV,_mysql=_interopRequireDefault(require("mysql2"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var env=null!==(_process$env$NODE_ENV=process.env.NODE_ENV)&&void 0!==_process$env$NODE_ENV?_process$env$NODE_ENV:"testing",config=require("./config")[env],userConnection=_mysql["default"].createPool({host:config.database.host,user:config.database.user,password:config.database.password,port:config.database.port,database:config.database.dbUser,waitForConnections:!0,connectionLimit:10,queueLimit:0});userConnection.query("USE "+config.database.dbUser);// ==== PROJECT DB CONNECTION ====
var projectConnection=_mysql["default"].createPool({host:config.database.host_project,user:config.database.user,password:config.database.password,port:config.database.port,database:config.database.dbProject,waitForConnections:!0,connectionLimit:10,queueLimit:0});projectConnection.query("USE "+config.database.dbProject);var dbConnection={user:userConnection,project:projectConnection};exports.dbConnection=dbConnection;
\ No newline at end of file
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mailer=void 0;var _process$env$NODE_ENV,nodemailer=require("nodemailer"),nodemailerNTLMAuth=require("nodemailer-ntlm-auth"),env=null!==(_process$env$NODE_ENV=process.env.NODE_ENV)&&void 0!==_process$env$NODE_ENV?_process$env$NODE_ENV:"testing",config=require("./config")[env],smtpTransporter=nodemailer.createTransport({host:config.mailer.host,secure:config.mailer.secureConnection,port:config.mailer.port,requireTLS:config.mailer.TLS,auth:{type:"custom",method:"NTLM",user:config.mailer.authUser,pass:config.mailer.authPass,options:{domain:"ad"}},customAuth:{NTLM:nodemailerNTLMAuth}}),mailOptions={to:"",cc:"",from:config.mailer.from,subject:"",text:"",html:""},mailer={transporter:smtpTransporter,options:mailOptions};exports.mailer=mailer;
\ No newline at end of file
"use strict";var _dbconn=require("../config/dbconn");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.dbController=void 0;function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,e,f){var g=b&&b.prototype instanceof d?b:d,h=Object.create(g.prototype),j=new l(f||[]);return h._invoke=function(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return n()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var j=i(h,d);if(j){if(j===v)continue;return j}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;this._invoke=function(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}}function i(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void 0,i(a,b),"throw"===b.method))return v;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,v;var f=e.arg;return f?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,v):f:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,v)}function j(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function k(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function l(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}function m(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:n}}function n(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return o};var o={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}o.wrap=b;var v={},w={};a(w,s,function(){return this});var x=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);var z=f.prototype=d.prototype=Object.create(w);return e.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){return this}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return o.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){return this}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),k(b),v},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;k(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),v}},o}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}var dbController={// ===================== user db =====================
registerNewUser:function registerNewUser(a,b){_dbconn.dbConnection.user.getConnection(function(c,d){d.beginTransaction(function(b){// START TRANSACTION
if(b)throw b;// insert profile
d.query("INSERT INTO user SET ?",a.profile,function(b,c){if(b)return d.rollback(function(){throw b});var e=c.insertId,f={user_id:e,password:a.password};// set password
d.query("INSERT INTO credential SET ?",f,function(b){if(b)return d.rollback(function(){throw b});// set default user-project-role
d.query("INSERT INTO user_project_role SET ?",{project_id:1,// M4_LAB
role_id:2,// USER
user_id:e},function(b){if(b)return d.rollback(function(){throw b});// MLAB-129: INSERT verification token
var c={user_id:e,token:a.verificationToken};d.query("INSERT INTO verification SET ?",c,function(a){return a?d.rollback(function(){throw a}):void// COMMIT
d.commit(function(a){if(a)return d.rollback(function(){throw a})})})})})})}),b(c)})},getUserByEmail:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,_dbconn.dbConnection.user.promise().query("SELECT id, verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = \""+a+"\"");case 3:if(c=b.sent,!c[0][0]){b.next=8;break}return b.abrupt("return",c[0][0]);case 8:return b.abrupt("return",null);case 9:b.next=14;break;case 11:b.prev=11,b.t0=b["catch"](0),console.error(b.t0);case 14:return b.abrupt("return",null);case 15:case"end":return b.stop();}},b,null,[[0,11]])}));return a}(),getUserEmailById:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,_dbconn.dbConnection.user.promise().query("SELECT email FROM user WHERE id = "+a);case 3:if(c=b.sent,!c[0][0]){b.next=8;break}return b.abrupt("return",c[0][0].email);case 8:return b.abrupt("return",null);case 9:b.next=14;break;case 11:b.prev=11,b.t0=b["catch"](0),console.error(b.t0);case 14:return b.abrupt("return",null);case 15:case"end":return b.stop();}},b,null,[[0,11]])}));return a}(),checkUserEmail:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,_dbconn.dbConnection.user.promise().query("SELECT id, email FROM user WHERE email = \""+a+"\"");case 3:if(c=b.sent,!c[0][0]){b.next=8;break}return b.abrupt("return",c[0][0]);case 8:return b.abrupt("return",null);case 9:b.next=14;break;case 11:b.prev=11,b.t0=b["catch"](0),console.error(b.t0);case 14:return b.abrupt("return",null);case 15:case"end":return b.stop();}},b,null,[[0,11]])}));return a}(),getUserByToken:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,_dbconn.dbConnection.user.promise().query("SELECT t1.user_id, t2.email FROM userdb.credential AS t1 INNER JOIN userdb.user AS t2 ON t1.user_id = t2.id AND t1.resetPasswordToken = \""+a+"\" and resetPasswordExpires > "+Date.now());case 3:if(c=b.sent,!c[0][0]){b.next=8;break}return b.abrupt("return",c[0][0]);case 8:return b.abrupt("return",null);case 9:b.next=14;break;case 11:b.prev=11,b.t0=b["catch"](0),console.error(b.t0);case 14:return b.abrupt("return",null);case 15:case"end":return b.stop();}},b,null,[[0,11]])}));return a}(),updateUserById:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d;return _regeneratorRuntime().wrap(function e(c){for(;1;)switch(c.prev=c.next){case 0:return c.prev=0,c.next=3,_dbconn.dbConnection.user.promise().query("UPDATE user SET ? WHERE id = "+a,b);case 3:return d=c.sent,c.abrupt("return",d);case 7:c.prev=7,c.t0=c["catch"](0),console.error(c.t0);case 10:return c.abrupt("return",null);case 11:case"end":return c.stop();}},c,null,[[0,7]])}));return a}(),updateCredential:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,_dbconn.dbConnection.user.promise().query("UPDATE credential SET ? WHERE user_id = "+a.user_id,a);case 3:return c=b.sent,b.abrupt("return",c);case 7:b.prev=7,b.t0=b["catch"](0),console.error(b.t0);case 10:return b.abrupt("return",null);case 11:case"end":return b.stop();}},b,null,[[0,7]])}));return a}(),addUserProjectRole_OBSOLETE:function addUserProjectRole_OBSOLETE(a,b){_dbconn.dbConnection.user.query("INSERT INTO user_project_role SET ?",a,function(a){if(a)throw a;b(a)})},getVerificationTokenByUserId:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,_dbconn.dbConnection.user.promise().query("SELECT token FROM verification WHERE user_id = \""+a+"\"");case 3:if(c=b.sent,!c[0][0]){b.next=8;break}return b.abrupt("return",c[0][0].token);case 8:return b.abrupt("return",null);case 9:b.next=14;break;case 11:b.prev=11,b.t0=b["catch"](0),console.error(b.t0);case 14:return b.abrupt("return",null);case 15:case"end":return b.stop();}},b,null,[[0,11]])}));return a}(),getUserIdByVerificationToken:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,_dbconn.dbConnection.user.promise().query("SELECT user_id FROM verification WHERE token = \""+a+"\"");case 3:if(c=b.sent,!c[0][0]){b.next=8;break}return b.abrupt("return",c[0][0].user_id);case 8:return b.abrupt("return",null);case 9:b.next=14;break;case 11:b.prev=11,b.t0=b["catch"](0),console.error(b.t0);case 14:return b.abrupt("return",null);case 15:case"end":return b.stop();}},b,null,[[0,11]])}));return a}(),verifyUserAccount:function verifyUserAccount(a,b){_dbconn.dbConnection.user.getConnection(function(c,d){d.beginTransaction(function(b){// START TRANSACTION
if(b)throw b;// update user status
d.query("UPDATE user SET ? WHERE id ="+a.id,a,function(b,c,e){return b?d.rollback(function(){throw b}):void// delete verification token
d.query("DELETE FROM verification WHERE user_id = "+a.id,function(a,b,c){return a?d.rollback(function(){throw a}):void// COMMIT
d.commit(function(a){if(a)return d.rollback(function(){throw a})})})})}),b(c)})},/* ===== GitLab ===== */getGitlabId:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,_dbconn.dbConnection.user.promise().query("SELECT gu.gitlab_userId FROM user_gitlab gu, user u WHERE u.id = \""+a+"\" and gu.user_id = u.id");case 3:if(c=b.sent,!c[0][0]){b.next=8;break}return b.abrupt("return",c[0][0].gitlab_userId);case 8:return b.abrupt("return",null);case 9:b.next=15;break;case 11:return b.prev=11,b.t0=b["catch"](0),console.error(b.t0),b.abrupt("return",b.t0);case 15:case"end":return b.stop();}},b,null,[[0,11]])}));return a}(),addGitlabUser:function addGitlabUser(a,b){_dbconn.dbConnection.user.query("INSERT INTO user_gitlab SET ?",a,function(a){if(a)throw a;b(a)})}};exports.dbController=dbController;
\ No newline at end of file
"use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.gitlabController=void 0;var _process$env$NODE_ENV,_axios=_interopRequireDefault(require("axios")),_fs=_interopRequireDefault(require("fs")),_formData=_interopRequireDefault(require("form-data"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,e,f){var g=b&&b.prototype instanceof d?b:d,h=Object.create(g.prototype),j=new l(f||[]);return h._invoke=function(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return n()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var j=i(h,d);if(j){if(j===v)continue;return j}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;this._invoke=function(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}}function i(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void 0,i(a,b),"throw"===b.method))return v;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,v;var f=e.arg;return f?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,v):f:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,v)}function j(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function k(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function l(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}function m(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:n}}function n(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return o};var o={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}o.wrap=b;var v={},w={};a(w,s,function(){return this});var x=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);var z=f.prototype=d.prototype=Object.create(w);return e.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){return this}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return o.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){return this}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),k(b),v},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;k(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),v}},o}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}var env=null!==(_process$env$NODE_ENV=process.env.NODE_ENV)&&void 0!==_process$env$NODE_ENV?_process$env$NODE_ENV:"testing",config=require("../config/config")[env],gitlabController={getUserByEmail:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){return _regeneratorRuntime().wrap(function c(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,(0,_axios["default"])({method:"get",url:"https://transfer.hft-stuttgart.de/gitlab/api/v4/users?search="+a,headers:{Authorization:"Bearer "+config.gitlab.token_readWriteProjects}}).then(function(a){return a.data[0]})["catch"](function(a){return console.error(a),null});case 2:return b.abrupt("return",b.sent);case 3:case"end":return b.stop();}},b)}));return a}(),createNewPages:function(){function a(a,c,d){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,b,c){var e;return _regeneratorRuntime().wrap(function f(d){for(;1;)switch(d.prev=d.next){case 0:return e=new _formData["default"],e.append("avatar",_fs["default"].createReadStream(b)),d.next=4,(0,_axios["default"])({method:"post",url:"https://transfer.hft-stuttgart.de/gitlab/api/v4/projects/user/"+(a.getOwnerGitlabId()+"?name=")+(a.getName()+"&description=")+(a.getDesc()+"&tag_list=website&use_custom_template=true&template_name=")+c,headers:_objectSpread({Authorization:"Bearer "+config.gitlab.token_readWriteProjects},e.getHeaders()),data:e}).then(function(a){return a.data})["catch"](function(a){return console.error("ERR Status: "+a.response.status),console.error("ERR Name: "+a.response.data.message.name),console.error("ERR Path: "+a.response.data.message.path),a.response});case 4:return d.abrupt("return",d.sent);case 5:case"end":return d.stop();}},d)}));return a}(),updateProject:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d;return _regeneratorRuntime().wrap(function e(c){for(;1;)switch(c.prev=c.next){case 0:return d=new _formData["default"],b&&d.append("avatar",_fs["default"].createReadStream(b)),c.next=4,(0,_axios["default"])({method:"put",url:"https://transfer.hft-stuttgart.de/gitlab/api/v4/projects/"+a.getId()+"?name="+a.getName()+"&description="+a.getDesc(),headers:_objectSpread({Authorization:"Bearer "+config.gitlab.token_readWriteProjects},d.getHeaders()),data:d})// .then(res => res.data[0])
.then(function(a){return a.data})["catch"](function(a){return console.error("ERR Status: "+a.response.status),console.error("ERR Name: "+a.response.data.message.name),console.error("ERR Path: "+a.response.data.message.path),a.response});case 4:return c.abrupt("return",c.sent);case 5:case"end":return c.stop();}},c)}));return a}(),deleteProjectById:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){return _regeneratorRuntime().wrap(function c(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,(0,_axios["default"])({method:"delete",url:"https://transfer.hft-stuttgart.de/gitlab/api/v4/projects/"+a,headers:{Authorization:"Bearer "+config.gitlab.token_readWriteProjects}}).then(function(a){return!0})["catch"](function(a){return console.error("ERR Status: "+a.response.status),console.error("ERR Name: "+a.response.data.message.name),console.error("ERR Path: "+a.response.data.message.path),!1});case 2:return b.abrupt("return",b.sent);case 3:case"end":return b.stop();}},b)}));return a}(),getUserProjects:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){return _regeneratorRuntime().wrap(function c(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,(0,_axios["default"])({method:"get",url:"https://transfer.hft-stuttgart.de/gitlab/api/v4/users/"+a+"/projects?owned=true&visibility=public",headers:{Authorization:"Bearer "+config.gitlab.token_readWriteProjects}}).then(function(a){return a.data})["catch"](function(a){return console.error(a),null});case 2:return b.abrupt("return",b.sent);case 3:case"end":return b.stop();}},b)}));return a}(),getProjectById:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){return _regeneratorRuntime().wrap(function c(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,(0,_axios["default"])({method:"get",url:"https://transfer.hft-stuttgart.de/gitlab/api/v4/projects/"+a,headers:{Authorization:"Bearer "+config.gitlab.token_readWriteProjects}}).then(function(a){return a.data})["catch"](function(a){return console.error(a),null});case 2:return b.abrupt("return",b.sent);case 3:case"end":return b.stop();}},b)}));return a}(),getProjectPipelineLatestStatus:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){return _regeneratorRuntime().wrap(function c(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,(0,_axios["default"])({method:"get",url:"https://transfer.hft-stuttgart.de/gitlab/api/v4/projects/"+a+"/pipelines"}).then(function(a){return a.data[0].status})["catch"](function(a){return console.error(a),null});case 2:return b.abrupt("return",b.sent);case 3:case"end":return b.stop();}},b)}));return a}()};exports.gitlabController=gitlabController;
\ No newline at end of file
"use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.publicController=void 0;var _async=_interopRequireDefault(require("async")),_bcryptjs=_interopRequireDefault(require("bcryptjs")),_mailer=require("../config/mailer"),_const=require("../config/const"),_dbController=require("./dbController");function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,e,f){var g=b&&b.prototype instanceof d?b:d,h=Object.create(g.prototype),j=new l(f||[]);return h._invoke=function(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return n()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var j=i(h,d);if(j){if(j===v)continue;return j}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;this._invoke=function(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}}function i(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void 0,i(a,b),"throw"===b.method))return v;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,v;var f=e.arg;return f?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,v):f:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,v)}function j(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function k(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function l(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}function m(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:n}}function n(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return o};var o={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}o.wrap=b;var v={},w={};a(w,s,function(){return this});var x=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);var z=f.prototype=d.prototype=Object.create(w);return e.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){return this}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return o.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){return this}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),k(b),v},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;k(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),v}},o}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}var saltRounds=10,publicController={showRegistrationPage:function showRegistrationPage(a,b){a.render(b+"/account/registration")},showContactPage:function showContactPage(a,b,c){b.render(c+"/account/contact",{user:a.user})},showForgotPwdPage:function showForgotPwdPage(a,b,c){b.render(c+"/account/forgotPwd",{user:a.user})},showResetPassword:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,b,c){var e;return _regeneratorRuntime().wrap(function f(d){for(;1;)switch(d.prev=d.next){case 0:return d.next=2,_dbController.dbController.getUserByToken(a.params.token);case 2:e=d.sent,e?b.render(c+"/account/reset"):(b.flash("error","Der Schl\xFCssel zum zur\xFCcksetzen des Passworts ist ung\xFCltig oder abgelaufen."),b.redirect("/account/forgotPwd"));case 4:case"end":return d.stop();}},d)}));return a}(),sendContactMessage:function sendContactMessage(a,b){var c=a.body.inputEmail,d="support-transfer@hft-stuttgart.de",e=a.body.name,f=a.body.message,g="Ihre Anfrage an das Transferportal",h="<div>Es wurde eine Anfrage an das Transferportal gestellt: <br/><br/>NAME: "+e+"<br/>NACHRICHT: "+f+"</div>";_async["default"].waterfall([function(a){// send email
_mailer.mailer.options.to=d,_mailer.mailer.options.cc=c,_mailer.mailer.options.subject=g,_mailer.mailer.options.html=h,_mailer.mailer.transporter.sendMail(_mailer.mailer.options,function(b){a(b,"done")})}],function(a){a?(console.error(a),b.flash("error","Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.")):b.flash("success","Vielen Dank f\xFCr Ihre Anfrage. Wir melden uns baldm\xF6glichst bei Ihnen. Eine Kopie Ihrer Anfrage wurde an "+c+" versandt."),b.redirect("/account/contact")})},registerUser:function registerUser(a,b,c){// user data
var d=new Date,e={salutation:a.body.inputSalutation,title:a.body.inputTitle,firstname:a.body.inputFirstname,lastname:a.body.inputLastname,email:a.body.inputEmail,organisation:a.body.inputOrganisation,industry:a.body.inputIndustry,speciality:a.body.inputSpeciality,createdDate:d.toISOString().slice(0,10)},f=e.email,g=f.indexOf("@"),h=f.length,i=f.slice(g,h);"@hft-stuttgart.de"===i.toLowerCase()?(b.flash("error","Fehlgeschlagen: HFT-Account"),b.redirect("/account/registration")):_async["default"].waterfall([function(b){// generate token
for(var c="",d="abcdefghijklmnopqrstuvwxyz0123456789",f=0;40>f;f++)c+=d.charAt(Math.floor(Math.random()*d.length));// encrypt password
_bcryptjs["default"].genSalt(saltRounds,function(d,f){_bcryptjs["default"].hash(a.body.inputPassword,f,function(a,d){var f={profile:e,password:d,verificationToken:c};b(a,f)})})},// save data
function(d,e){_dbController.dbController.registerNewUser(d,function(e){if(e)b.flash("error","Fehlgeschlagen");else{// send email
var f="Bitte best\xE4tigen Sie Ihr M4_LAB Benutzerkonto",g="<div>Lieber Nutzer,<br/><br/><p>vielen Dank f\xFCr Ihre Anmeldung am Transferportal der HFT Stuttgart. <br/>Um Ihre Anmeldung zu best\xE4tigen, klicken Sie bitte <a href="+(c.app.host+"")+"/verifyAccount?token="+(d.verificationToken+"")+">diesen Link</a> <br/><br/>Ohne Best\xE4tigung Ihres Kontos m\xFCssen wir Ihr Konto leider nach 7 Tagen l\xF6schen.</p><br/>"+(_const.miscConst.mailSignature+"")+"</div>";// user feedback
_mailer.mailer.options.to=a.body.inputEmail,_mailer.mailer.options.subject="Bitte best\xE4tigen Sie Ihr M4_LAB Benutzerkonto",_mailer.mailer.options.html=g,_mailer.mailer.transporter.sendMail(_mailer.mailer.options,function(a){if(a)throw console.error("Cannot send email. [Error] "+(a+"")),a}),b.flash("success","Vielen Dank f\xFCr Ihre Registrierung!\r\n\r\nWir haben Ihnen eine E-Mail an Ihre verwendete Adresse gesendet. Diese enth\xE4lt einen Link zur Best\xE4tigung Ihres Accounts.\r\nWenn Sie die Mail nicht in ihrem Postfach vorfinden, pr\xFCfen Sie bitte auch Ihren Spam-Ordner.")}b.redirect("/account/registration")})}])},verifyAccount:function(){function a(a,c,d){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,b,c){var e,f;return _regeneratorRuntime().wrap(function g(d){for(;1;)switch(d.prev=d.next){case 0:return d.next=2,_dbController.dbController.getUserIdByVerificationToken(a.query.token);case 2:e=d.sent,e?(f={id:e,verificationStatus:1},_dbController.dbController.verifyUserAccount(f,/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a){var f,g,h;return _regeneratorRuntime().wrap(function i(d){for(;1;)switch(d.prev=d.next){case 0:if(!a){d.next=5;break}console.error(a),b.render(c+"/account/verification",{status:!1}),d.next=9;break;case 5:return d.next=7,_dbController.dbController.getUserEmailById(e);case 7:f=d.sent,f?(g="Herzlich willkommen",h="<div>Lieber Nutzer,<br/><br/><p>herzlich willkommen beim Transferportal der HFT Stuttgart!<br/>Sie k\xF6nnen nun alle Dienste des Portals nutzen.<p/><br/>"+_const.miscConst.mailSignature,_mailer.mailer.options.to=f,_mailer.mailer.options.subject=g,_mailer.mailer.options.html=h,_mailer.mailer.transporter.sendMail(_mailer.mailer.options,function(a){if(a)throw console.log("cannot send email"),a}),b.render(c+"/account/verification",{status:!0})):b.render(c+"/account/verification",{status:!1});case 9:case"end":return d.stop();}},d)}));return function(b){return a.apply(this,arguments)}}())):b.render(c+"/account/verification",{status:null});case 4:case"end":return d.stop();}},d)}));return a}(),resetPassword:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,e;return _regeneratorRuntime().wrap(function f(c){for(;1;)switch(c.prev=c.next){case 0:return d=a.body.inputNewPwd,c.next=3,_dbController.dbController.getUserByToken(a.params.token);case 3:e=c.sent,e?_bcryptjs["default"].genSalt(saltRounds,function(a,c){_bcryptjs["default"].hash(d,c,/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,c){var f,g;return _regeneratorRuntime().wrap(function d(a){for(;1;)switch(a.prev=a.next){case 0:return f={password:c,user_id:e.user_id,resetPasswordToken:null,resetPasswordExpires:null},a.next=3,_dbController.dbController.updateCredential(f);case 3:g=a.sent,g?(b.flash("success","Passwort aktualisiert!"),_mailer.mailer.options.to=e.email,_mailer.mailer.options.subject=_const.miscConst.updatePasswordMailSubject,_mailer.mailer.options.html=_const.miscConst.updatePasswordMailContent+"<div>"+_const.miscConst.mailSignature+"</div>",_mailer.mailer.transporter.sendMail(_mailer.mailer.options,function(a){a&&console.log(a)})):(console.log("Failed to reset password"),b.flash("error","Datenbankfehler: Passwort kann nicht ge\xE4ndert werden.")),b.redirect("/login");case 6:case"end":return a.stop();}},d)}));return function(b,c){return a.apply(this,arguments)}}())}):(b.flash("error","User not found."),b.redirect("/login"));case 5:case"end":return c.stop();}},c)}));return a}(),generateNewToken:function generateNewToken(a,b,c){var d=Math.floor,e=a.body.inputEmail;_async["default"].waterfall([/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var f,g,h,j,k,l,m,n;return _regeneratorRuntime().wrap(function i(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,_dbController.dbController.checkUserEmail(e);case 2:if(f=b.sent,f){b.next=7;break}console.log("No user found: "+(e+"")),b.next=17;break;case 7:for(g="",h="abcdefghijklmnopqrstuvwxyz0123456789",j=0;40>j;j++)g+=h.charAt(d(Math.random()*h.length));return k="Ihre Passwort-Anfrage an das Transferportal der HFT Stuttgart",l="<div>Lieber Nutzer,<br/><br/><p>wir haben Ihre Anfrage zur Erneuerung Ihres Passwortes erhalten. Falls Sie diese Anfrage nicht gesendet haben, ignorieren Sie bitte diese E-Mail.<br/><br/>Sie k\xF6nnen Ihr Passwort mit dem Klick auf diesen Link \xE4ndern: "+(c.app.host+"/reset/")+(g+"<br/>Dieser Link ist aus Sicherheitsgr\xFCnden nur f\xFCr 1 Stunde g\xFCltig.<br/></p>")+(_const.miscConst.mailSignature+"</div>"),m={user_id:f.id,resetPasswordToken:g,resetPasswordExpires:Date.now()+36e5// 1 hour
},b.next=15,_dbController.dbController.updateCredential(m);case 15:n=b.sent,n?(_mailer.mailer.options.to=e,_mailer.mailer.options.subject=k,_mailer.mailer.options.html=l,_mailer.mailer.transporter.sendMail(_mailer.mailer.options,function(a){a&&console.error(a)})):console.log("failed to update credential");case 17:a(null);case 18:case"end":return b.stop();}},b)}));return function(b){return a.apply(this,arguments)}}()],function(a){a?b.flash("error","Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut."):b.flash("success","Wenn Ihre E-Mail-Adresse registriert ist, wurde eine E-Mail mit dem weiteren Vorgehen an "+(e+"")+" versendet."),b.redirect("/account/forgotPwd")})},checkUserEmail:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d;return _regeneratorRuntime().wrap(function e(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,_dbController.dbController.checkUserEmail(a.params.email);case 2:d=c.sent,d?b.send(!1):b.send(!0);case 4:case"end":return c.stop();}},c)}));return a}()};exports.publicController=publicController;
\ No newline at end of file
// password requirement
function checkPasswordReq (pwd) {
if (pwd.length < 8) {
isBest = false
} else {
isBest = true
}
return isBest
}
const menu = [{ name: 'Informationen', combos: [{ name: 'Projekte', link: '/project' }, { name: 'Über das M4_LAB', link: '/projectoverview?projectID=1' }, { name: 'Kontakt', link: '/account/contact' }], type: 'dropdown', link: '#' }, { name: 'Zusammenarbeit', combos: [{ name: 'Mailinglisten', link: '/mailinglists' }, { name: 'Videokonferenzen', link: '/videoconference.html' }/* {'name':'...', 'link':'#'} */], type: 'dropdown', link: '#' }, { name: 'Events', combos: [{ name: 'Veranstaltungen der HfT', link: 'http://www.hft-stuttgart.de/Aktuell/Veranstaltungen/' }, { name: 'Veranstaltungen der HfT Forschung', link: 'https://www.hft-stuttgart.de/forschung/veranstaltungen' }], type: 'dropdown', link: '#' }, { name: 'Benutzerkonto', combos: [], type: '', link: '/account/' }]
const hft_links = [{ url: '/account/contact', name: 'Kontakt' }, { url: 'https://www.hft-stuttgart.de/impressum', name: 'Impressum' }, { url: 'https://www.hft-stuttgart.de/datenschutz', name: 'Datenschutz' }]
const socialmedias = [{ url: 'https://twitter.com/InnolabM4', name: 'fa-twitter' }, { url: 'https://www.facebook.com/HfTStuttgart/', name: 'fa-facebook-square' }, { url: 'https://www.instagram.com/m4_lab/', name: 'fa-instagram' }, { url: 'https://de.linkedin.com/school/hochschule-f%C3%BCr-technik-stuttgart-%E2%80%93-university-of-applied-sciences/', name: 'fa-linkedin' }, { url: 'https://www.youtube.com/channel/UCi0_JfF2qMZbOhOnNH5PyHA', name: 'fa-youtube' }]
const footer_images = [{ src: '/images/demo/Innovative_Hochschule_Initiative_BMBF_GWK_RGB.jpg', alt: 'Innovative Hochschule' }]
function prependChild (parent, child) {
parent.insertBefore(child, parent.childNodes[0])
}
function readCookie (cname) {
const name = cname + '='
const decodedCookie = decodeURIComponent(document.cookie)
const ca = decodedCookie.split(';')
for (let i = 0; i < ca.length; i++) {
let c = ca[i]
while (c.charAt(0) == ' ') {
c = c.substring(1)
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length)
}
}
return ''
}
function sendRequest (URL) {
console.log(document.cookie)
const xhr = new XMLHttpRequest()
xhr.open('POST', URL, true)
const token = readCookie('XSRF-TOKEN')
// Send the proper header information along with the request
xhr.setRequestHeader('X-CSRF-TOKEN', token)
xhr.send()
}
/* function head()
* creates header and prepends it to the documents body
*/
function head () {
const navheader = document.createElement('header')
navheader.id = 'header'
navheader.classList.add('clear')
// disclaimer
const alertdiv = document.createElement('div')
alertdiv.classList.add('alert', 'alert-danger', 'alert-dismissible', 'fade', 'show')
alertdiv.style = 'text-align:center;'
alertdiv.innerHTML = '<strong>Disclaimer</strong> This website is under construction and in prototype-phase. It is not for public use.'
const alertbutton = document.createElement('button')
alertbutton.type = 'button'
alertbutton.classList.add('close')
alertbutton.setAttribute('data-dismiss', 'alert')
alertbutton.innerHTML = '&times;'
prependChild(alertdiv, alertbutton)
// navigation header
const navbar = document.createElement('nav')
navbar.classList.add('navbar', 'navbar-expand-md', 'navbar-light')
navbar.style = 'background-color: #ffffff;'
const navbarcontainer = document.createElement('div')
navbarcontainer.classList.add('container')
const navbarheader = document.createElement('div')
navbarheader.classList.add('navbar-header')
// navigation header - logo
const link_m4lab = document.createElement('a')
link_m4lab.href = '/'
link_m4lab.classList.add('navbar-brand')
link_m4lab.innerHTML = "<img src='/img/header/Logozeile_Header.png' alt='Logo Innovationslabor M4_LAB'>"
navbarheader.appendChild(link_m4lab)
// navigation header - toggle button menu for mobile devices
const togglebutton = document.createElement('button')
togglebutton.classList.add('navbar-toggler')
togglebutton.type = 'button'
togglebutton.setAttribute('data-toggle', 'collapse')
togglebutton.setAttribute('data-target', '#navbarCollapse')
togglebutton.setAttribute('aria-controls', 'navbarCollapse')
togglebutton.setAttribute('aria-expanded', 'false')
togglebutton.setAttribute('aria-label', 'Toggle navigation')
togglebutton.innerHTML = "<span class='navbar-toggler-icon'></span>"
// nav menu
const navelements = document.createElement('ul')
navelements.id = 'navbarCollapse'
navelements.classList.add('collapse', 'nav', 'navbar-collapse', 'navbar-nav', 'justify-content-end')
for (let j = 0; j < menu.length; j++) {
const headitem = document.createElement('li')
const itemtype = menu[j].type
headitem.classList.add('nav-item')
const headlink = document.createElement('a')
headlink.href = menu[j].link
headlink.id = 'navbarDropdown' + j
headlink.classList.add('nav-link')
headlink.setAttribute('role', 'button')
if (itemtype == 'dropdown') {
headitem.classList.add('dropdown')
headlink.classList.add('dropdown-toggle')
headlink.setAttribute('data-toggle', 'dropdown')
headlink.setAttribute('aria-haspopup', 'true')
headlink.setAttribute('aria-expanded', 'false')
}
headlink.innerHTML = menu[j].name
if (itemtype == 'dropdown') {
const combodiv = document.createElement('div')
combodiv.id = headlink.id + '_par'
combodiv.setAttribute('aria-labelledby', headlink.id)
combodiv.classList.add('dropdown-menu')
for (let k = 0; k < menu[j].combos.length; k++) {
const combolink = document.createElement('a')
combolink.classList.add('dropdown-item')
combolink.href = menu[j].combos[k].link
combolink.innerHTML = menu[j].combos[k].name
combodiv.appendChild(combolink)
}
headitem.appendChild(combodiv)
}
prependChild(headitem, headlink)
navelements.appendChild(headitem)
}
navbarcontainer.appendChild(navbarheader)
navbarcontainer.appendChild(togglebutton)
navbarcontainer.appendChild(navelements)
navbar.appendChild(navbarcontainer)
navheader.appendChild(alertdiv)
navheader.appendChild(navbar)
prependChild(document.body, navheader)
}
/* function foot()
* creates footer and appends it to the documents body
*/
function foot () {
// add styles to <head> to manage sticky footer
const styles = `
@media only screen and (min-width: 768px) {
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 120px; /* Margin bottom by footer height */
}
#homepage {
position: absolute;
bottom: 0;
width: 100%;
text-align: center;
}
}
`
const styleSheet = document.createElement('style')