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

Merge branch 'cherry-pick-8a96a807' into 'testing'

MLAB-677: Deactivate routes to Projekt und Dienste

See merge request !172
parents b7da7ca8 665e8cec
Pipeline #6899 passed with stage
in 5 seconds
......@@ -8,5 +8,5 @@ cert:_fs["default"].readFileSync(__dirname+"/cert/cert_idp.pem","utf8"),validate
// to generate Service Provider's XML metadata
// ============= NEW GITLAB PAGES ===========================
// update a website
c.use(g),a.post(b.passport.saml.path,c.authenticate(b.passport.strategy,{failureRedirect:"/account/",failureFlash:!0}),function(a,b){b.redirect("/account/")}),a.get("/saml/metadata",function(a,b){b.type("application/xml");var c=g.generateServiceProviderMetadata(_fs["default"].readFileSync(__dirname+"/cert/cert.pem","utf8"));b.status(200).send(c)}),a.get("/",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f;return _regeneratorRuntime().wrap(function g(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:f=c.sent,null==f?(console.error("user data is not found"),b.status(500).render(d+"/500",{error:"Your data is not found. Please try again."})):b.render(d+"/account/home",{user:f});case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/login",c.authenticate(b.passport.strategy,{successRedirect:"/",failureRedirect:"/login"})),a.get("/logout",function(a,b){return null==a.user?b.redirect("/"):(a.user.nameID=a.user.id,a.user.nameIDFormat=a.user.idFormat,g.logout(a,function(c,d){return a.logout(),a.session&&a.session.destroy(function(a){if(a)return console.log(a)}),b.redirect(d)}))}),a.get("/profile",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f;return _regeneratorRuntime().wrap(function g(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:f=c.sent,null==f?b.redirect("/account/"):1===f.getVerificationStatus()?b.render(d+"/account/profile",{user:f}):b.redirect("/account/");case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/services",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=45;break;case 4:return c.next=6,e(a.user.email);case 6:if(f=c.sent,null!=f){c.next=11;break}b.redirect("/account/"),c.next=45;break;case 11:if(1===f.getVerificationStatus()){c.next=15;break}b.redirect("/account/"),c.next=45;break;case 15:if(g=[],h=[],!f.getGitlabUserId()){c.next=41;break}return c.next=20,_gitlabController.gitlabController.getUserProjects(f.getGitlabUserId());case 20:if(i=c.sent,!i){c.next=38;break}c.t0=_regeneratorRuntime().keys(i);case 23:if((c.t1=c.t0()).done){c.next=38;break}if(j=c.t1.value,!i[j].tag_list.includes("website")){c.next=34;break}return c.t2=new _website.Website(f.getGitlabUserId(),i[j].name,i[j].description,i[j].id,i[j].avatar_url,i[j].path_with_namespace),c.next=29,_gitlabController.gitlabController.getProjectPipelineLatestStatus(i[j].id);case 29:c.t3=c.sent,k={projectInformation:c.t2,pipelineStatus:c.t3},h.push(k),c.next=36;break;case 34:l=new _repo.Repo(f.getGitlabUserId(),i[j].name,i[j].description,i[j].id,i[j].avatar_url,i[j].path_with_namespace),g.push(l);case 36:c.next=23;break;case 38:b.render(d+"/account/services",{user:f,gitlabRepos:g,gitlabPages:h}),c.next=45;break;case 41:return c.next=43,_gitlabController.gitlabController.getUserByEmail(f.getEmail());case 43:m=c.sent,m?(n={user_id:f.getId(),gitlab_userId:m.id},_dbController.dbController.addGitlabUser(n,function(a){a?b.status(500).render(d+"/500",{error:a}):b.redirect("/account/services")})):b.render(d+"/account/services",{user:f,gitlabRepos:null,gitlabPages:null});case 45:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/security",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f;return _regeneratorRuntime().wrap(function g(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:f=c.sent,null==f?b.redirect("/account/"):1===f.getVerificationStatus()&&1===f.getIdpStatus()?b.render(d+"/account/security",{user:f}):b.redirect("/account/");case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.post("/updateProfile",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,f,g;return _regeneratorRuntime().wrap(function h(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=17;break;case 4:return c.next=6,e(a.user.email);case 6:if(d=c.sent,null!=d){c.next=11;break}b.redirect("/account/"),c.next=17;break;case 11:return f={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},c.next=14,_dbController.dbController.updateUserById(d.getId(),f);case 14:g=c.sent,g?(d.updateProfile(f.salutation,f.title,f.firstname,f.lastname,f.email,f.organisation,f.industry,f.speciality),b.flash("success","Ihr Benutzerprofil wurde aktualisiert!")):b.flash("error","Failed"),b.redirect("/account/profile");case 17:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.post("/changePwd",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f,g,h,i;return _regeneratorRuntime().wrap(function j(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:f=c.sent,null==f?b.redirect("/account/"):(g=a.body.inputCurrPwd,h=a.body.inputNewPwd,i=a.body.inputConfirm,_dbconn.dbConnection.user.query("SELECT password FROM credential WHERE user_id="+f.getId(),function(a,c){a&&(console.error(a),b.status(500).render(d+"/500",{error:a}));var e=c[0].password;// check if the password is correct
_bcryptjs["default"].compare(g,e,function(a,c){a?(console.error(a),b.status(500).render(d+"/500",{error:a})):c?h===i?_bcryptjs["default"].genSalt(saltRounds,function(a,c){_bcryptjs["default"].hash(h,c,/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,c){var e,g;return _regeneratorRuntime().wrap(function d(a){for(;1;)switch(a.prev=a.next){case 0:return e={password:c,user_id:f.getId()},a.next=3,_dbController.dbController.updateCredential(e);case 3:g=a.sent,g?(b.flash("success","Passwort aktualisiert!"),_mailer.mailer.options.to=f.getEmail(),_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("/account/security");case 6:case"end":return a.stop();}},d)}));return function(b,c){return a.apply(this,arguments)}}())}):(b.flash("error","Passw\xF6rter stimmen nicht \xFCberein. Bitte stellen Sie sicher, dass Sie das Passwort beide Male genau gleich eingeben."),b.redirect("/account/security")):(b.flash("error","Das Passwort ist leider falsch. Bitte \xFCberpr\xFCfen Sie Ihre Eingabe."),b.redirect("/account/security"))})}));case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/resendVerificationEmail",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,c){var f,g,h,i;return _regeneratorRuntime().wrap(function j(d){for(;1;)switch(d.prev=d.next){case 0:if(a.isAuthenticated){d.next=4;break}c.redirect("/login"),d.next=15;break;case 4:return d.next=6,e(a.user.email);case 6:if(f=d.sent,null!=f){d.next=11;break}c.redirect("/login"),d.next=15;break;case 11:return d.next=13,_dbController.dbController.getVerificationTokenByUserId(f.id);case 13:g=d.sent,g?(h="Bitte best\xE4tigen Sie Ihr M4_LAB Benutzerkonto",i="<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 diesen Link: "+b.app.host+"/verifyAccount?token="+g+"<br/><br/>Ohne Best\xE4tigung Ihres Kontos m\xFCssen wir Ihr Konto leider nach 7 Tagen l\xF6schen.</p><br/>"+_const.miscConst.mailSignature+"</div>",_mailer.mailer.options.to=f.email,_mailer.mailer.options.subject=h,_mailer.mailer.options.html=i,_mailer.mailer.transporter.sendMail(_mailer.mailer.options,function(a){if(a)throw console.log("cannot send email"),a}),c.send(!0)):c.send(!1);case 15:case"end":return d.stop();}},d)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/newInformation",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f,g;return _regeneratorRuntime().wrap(function h(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=15;break;case 4:return c.next=6,e(a.user.email);case 6:if(f=c.sent,null!=f){c.next=11;break}b.redirect("/login"),c.next=15;break;case 11:return c.next=13,_gitlabController.gitlabController.getUserByEmail(f.getEmail());case 13:g=c.sent,g?b.render(d+"/account/newInformation",{user:f,gitlabUsername:g.username}):b.redirect("/account/services");case 15:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.post("/newInformation",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,f,g,h,i,j;return _regeneratorRuntime().wrap(function k(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:d=c.sent,null==d?b.redirect("/login"):a.body.name||a.body.description?(f=a.body.name.toLowerCase().replace(/\s/g,"-"),g=a.body.description,h=a.body.template,i=new _website.Website(d.getGitlabUserId(),f,g),j=defaultLogo,a.files&&(j=a.files.logo),_async["default"].waterfall([function(b){a.files?j.mv(logoDir+j.name,function(a){j=logoDir+j.name,b(a,j)}):b(null,j)},/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a){var d;return _regeneratorRuntime().wrap(function e(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,_gitlabController.gitlabController.createNewPages(i,a,h);case 2:d=c.sent,d.status?("has already been taken"===d.data.message.name?b.flash("error","Der Projektname '"+i.getName()+"' ist bereits vergeben, bitte w\xE4hlen Sie einen anderen Namen."):b.flash("error","Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.\xA0"),b.redirect("/account/newInformation")):(b.flash("success","Ihre Webseite wurde erstellt, aber noch nicht ver\xF6ffentlicht. Um Ihre Webseite endg\xFCltig zu ver\xF6ffentlichen, schlie\xDFen Sie die Einrichtung gem\xE4\xDF unten stehender Anleitung ab."),b.redirect("/account/updateInformation?id="+(d.id+"")));case 4:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}()],function(b){null!=b&&console.log(b),a.files&&_fs["default"].unlink(j,function(a){null!=a&&console.log(a)})})):(b.flash("error","Bitte geben Sie die ben\xF6tigten Daten ein"),b.redirect("/account/newInformation"));case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/updateInformation",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f,g,h;return _regeneratorRuntime().wrap(function i(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=19;break;case 4:return c.next=6,e(a.user.email);case 6:if(f=c.sent,null!=f){c.next=11;break}b.redirect("/login"),c.next=19;break;case 11:if(a.query.id){c.next=15;break}b.redirect("/account/services"),c.next=19;break;case 15:return c.next=17,_gitlabController.gitlabController.getProjectById(a.query.id);case 17:g=c.sent,g?g.owner?g.owner.id===f.getGitlabUserId()?(h=new _website.Website(f.getGitlabUserId(),g.name,g.description,a.query.id,g.avatar_url,g.path_with_namespace),b.render(d+"/account/updateInformation",{user:f,information:h})):(console.log(" ========= Access denied: Not your project"),b.redirect("/account/services")):(console.log(" ========= Project cannot be accessed, since it does not have an owner"),b.redirect("/account/services")):(console.log(" ========= Error or no project found"),b.redirect("/account/services"));case 19:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.post("/updateInformation",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,f,g,h,i;return _regeneratorRuntime().wrap(function j(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:d=c.sent,null==d?b.redirect("/login"):a.body.name||a.body.description?(f=a.body.name.toLowerCase().replace(/\s/g,"-"),g=a.body.description,h=new _website.Website(d.getGitlabUserId(),f,g,a.query.id),_async["default"].waterfall([function(b){a.files?(i=a.files.logo,i.mv(logoDir+(i.name+""),function(a){i=logoDir+(i.name+""),b(a,i)})):b(null,i)},/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a){var d;return _regeneratorRuntime().wrap(function e(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,_gitlabController.gitlabController.updateProject(h,a);case 2:d=c.sent,d.status?"has already been taken"===d.data.message.name?b.flash("error","Der Projektname '"+(f+"' ist bereits vergeben, bitte w\xE4hlen Sie einen anderen Namen.")):b.flash("error","Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.\xA0"):(h.setLogo(d.avatar_url),h.setPath(d.path),b.flash("success","Ihre Website wurde aktualisiert")),b.redirect("/account/updateInformation?id="+(h.getId()+""));case 5:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}()],function(a){null!=a&&console.log(a),i&&_fs["default"].unlink(i,function(a){null!=a&&console.log(a)})})):(b.flash("error","Bitte geben Sie die ben\xF6tigten Daten ein"),b.redirect("/account/updateInformation"));case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a["delete"]("/deleteProject",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,f,g,h;return _regeneratorRuntime().wrap(function i(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=33;break;case 4:return c.next=6,e(a.user.email);case 6:if(d=c.sent,null!=d){c.next=11;break}b.redirect("/login"),c.next=33;break;case 11:if(f=a.body.id,!f){c.next=32;break}return c.next=15,_gitlabController.gitlabController.getProjectById(f);case 15:if(g=c.sent,g){c.next=20;break}console.log(" ========= Error or no project found"),c.next=32;break;case 20:if(g.owner){c.next=24;break}console.log(" ========= Project cannot be accessed, since it does not have an owner"),c.next=32;break;case 24:if(g.owner.id===d.getGitlabUserId()){c.next=28;break}console.log(" ========= Access denied: Not your project"),c.next=32;break;case 28:return c.next=30,_gitlabController.gitlabController.deleteProjectById(f);case 30:h=c.sent,h||b.flash("error","Project cannot be deleted. Please try again.");case 32:b.redirect("/account/services");case 33:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}())};
\ No newline at end of file
c.use(g),a.post(b.passport.saml.path,c.authenticate(b.passport.strategy,{failureRedirect:"/account/",failureFlash:!0}),function(a,b){b.redirect("/account/")}),a.get("/saml/metadata",function(a,b){b.type("application/xml");var c=g.generateServiceProviderMetadata(_fs["default"].readFileSync(__dirname+"/cert/cert.pem","utf8"));b.status(200).send(c)}),a.get("/",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f;return _regeneratorRuntime().wrap(function g(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:f=c.sent,null==f?(console.error("user data is not found"),b.status(500).render(d+"/500",{error:"Your data is not found. Please try again."})):b.render(d+"/account/home",{user:f});case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/login",c.authenticate(b.passport.strategy,{successRedirect:"/",failureRedirect:"/login"})),a.get("/logout",function(a,b){return null==a.user?b.redirect("/"):(a.user.nameID=a.user.id,a.user.nameIDFormat=a.user.idFormat,g.logout(a,function(c,d){return a.logout(),a.session&&a.session.destroy(function(a){if(a)return console.log(a)}),b.redirect(d)}))}),a.get("/profile",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f;return _regeneratorRuntime().wrap(function g(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:f=c.sent,null==f?b.redirect("/account/"):1===f.getVerificationStatus()?b.render(d+"/account/profile",{user:f}):b.redirect("/account/");case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/services_DEACTIVATED",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=45;break;case 4:return c.next=6,e(a.user.email);case 6:if(f=c.sent,null!=f){c.next=11;break}b.redirect("/account/"),c.next=45;break;case 11:if(1===f.getVerificationStatus()){c.next=15;break}b.redirect("/account/"),c.next=45;break;case 15:if(g=[],h=[],!f.getGitlabUserId()){c.next=41;break}return c.next=20,_gitlabController.gitlabController.getUserProjects(f.getGitlabUserId());case 20:if(i=c.sent,!i){c.next=38;break}c.t0=_regeneratorRuntime().keys(i);case 23:if((c.t1=c.t0()).done){c.next=38;break}if(j=c.t1.value,!i[j].tag_list.includes("website")){c.next=34;break}return c.t2=new _website.Website(f.getGitlabUserId(),i[j].name,i[j].description,i[j].id,i[j].avatar_url,i[j].path_with_namespace),c.next=29,_gitlabController.gitlabController.getProjectPipelineLatestStatus(i[j].id);case 29:c.t3=c.sent,k={projectInformation:c.t2,pipelineStatus:c.t3},h.push(k),c.next=36;break;case 34:l=new _repo.Repo(f.getGitlabUserId(),i[j].name,i[j].description,i[j].id,i[j].avatar_url,i[j].path_with_namespace),g.push(l);case 36:c.next=23;break;case 38:b.render(d+"/account/services",{user:f,gitlabRepos:g,gitlabPages:h}),c.next=45;break;case 41:return c.next=43,_gitlabController.gitlabController.getUserByEmail(f.getEmail());case 43:m=c.sent,m?(n={user_id:f.getId(),gitlab_userId:m.id},_dbController.dbController.addGitlabUser(n,function(a){a?b.status(500).render(d+"/500",{error:a}):b.redirect("/account/services")})):b.render(d+"/account/services",{user:f,gitlabRepos:null,gitlabPages:null});case 45:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/security",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f;return _regeneratorRuntime().wrap(function g(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:f=c.sent,null==f?b.redirect("/account/"):1===f.getVerificationStatus()&&1===f.getIdpStatus()?b.render(d+"/account/security",{user:f}):b.redirect("/account/");case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.post("/updateProfile",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,f,g;return _regeneratorRuntime().wrap(function h(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=17;break;case 4:return c.next=6,e(a.user.email);case 6:if(d=c.sent,null!=d){c.next=11;break}b.redirect("/account/"),c.next=17;break;case 11:return f={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},c.next=14,_dbController.dbController.updateUserById(d.getId(),f);case 14:g=c.sent,g?(d.updateProfile(f.salutation,f.title,f.firstname,f.lastname,f.email,f.organisation,f.industry,f.speciality),b.flash("success","Ihr Benutzerprofil wurde aktualisiert!")):b.flash("error","Failed"),b.redirect("/account/profile");case 17:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.post("/changePwd",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f,g,h,i;return _regeneratorRuntime().wrap(function j(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:f=c.sent,null==f?b.redirect("/account/"):(g=a.body.inputCurrPwd,h=a.body.inputNewPwd,i=a.body.inputConfirm,_dbconn.dbConnection.user.query("SELECT password FROM credential WHERE user_id="+f.getId(),function(a,c){a&&(console.error(a),b.status(500).render(d+"/500",{error:a}));var e=c[0].password;// check if the password is correct
_bcryptjs["default"].compare(g,e,function(a,c){a?(console.error(a),b.status(500).render(d+"/500",{error:a})):c?h===i?_bcryptjs["default"].genSalt(saltRounds,function(a,c){_bcryptjs["default"].hash(h,c,/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,c){var e,g;return _regeneratorRuntime().wrap(function d(a){for(;1;)switch(a.prev=a.next){case 0:return e={password:c,user_id:f.getId()},a.next=3,_dbController.dbController.updateCredential(e);case 3:g=a.sent,g?(b.flash("success","Passwort aktualisiert!"),_mailer.mailer.options.to=f.getEmail(),_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("/account/security");case 6:case"end":return a.stop();}},d)}));return function(b,c){return a.apply(this,arguments)}}())}):(b.flash("error","Passw\xF6rter stimmen nicht \xFCberein. Bitte stellen Sie sicher, dass Sie das Passwort beide Male genau gleich eingeben."),b.redirect("/account/security")):(b.flash("error","Das Passwort ist leider falsch. Bitte \xFCberpr\xFCfen Sie Ihre Eingabe."),b.redirect("/account/security"))})}));case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/resendVerificationEmail",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function d(a,c){var f,g,h,i;return _regeneratorRuntime().wrap(function j(d){for(;1;)switch(d.prev=d.next){case 0:if(a.isAuthenticated){d.next=4;break}c.redirect("/login"),d.next=15;break;case 4:return d.next=6,e(a.user.email);case 6:if(f=d.sent,null!=f){d.next=11;break}c.redirect("/login"),d.next=15;break;case 11:return d.next=13,_dbController.dbController.getVerificationTokenByUserId(f.id);case 13:g=d.sent,g?(h="Bitte best\xE4tigen Sie Ihr M4_LAB Benutzerkonto",i="<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 diesen Link: "+b.app.host+"/verifyAccount?token="+g+"<br/><br/>Ohne Best\xE4tigung Ihres Kontos m\xFCssen wir Ihr Konto leider nach 7 Tagen l\xF6schen.</p><br/>"+_const.miscConst.mailSignature+"</div>",_mailer.mailer.options.to=f.email,_mailer.mailer.options.subject=h,_mailer.mailer.options.html=i,_mailer.mailer.transporter.sendMail(_mailer.mailer.options,function(a){if(a)throw console.log("cannot send email"),a}),c.send(!0)):c.send(!1);case 15:case"end":return d.stop();}},d)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/newInformation_DEACTIVATED",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f,g;return _regeneratorRuntime().wrap(function h(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=15;break;case 4:return c.next=6,e(a.user.email);case 6:if(f=c.sent,null!=f){c.next=11;break}b.redirect("/login"),c.next=15;break;case 11:return c.next=13,_gitlabController.gitlabController.getUserByEmail(f.getEmail());case 13:g=c.sent,g?b.render(d+"/account/newInformation",{user:f,gitlabUsername:g.username}):b.redirect("/account/services");case 15:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.post("/newInformation_DEACTIVATED",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,f,g,h,i,j;return _regeneratorRuntime().wrap(function k(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:d=c.sent,null==d?b.redirect("/login"):a.body.name||a.body.description?(f=a.body.name.toLowerCase().replace(/\s/g,"-"),g=a.body.description,h=a.body.template,i=new _website.Website(d.getGitlabUserId(),f,g),j=defaultLogo,a.files&&(j=a.files.logo),_async["default"].waterfall([function(b){a.files?j.mv(logoDir+j.name,function(a){j=logoDir+j.name,b(a,j)}):b(null,j)},/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a){var d;return _regeneratorRuntime().wrap(function e(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,_gitlabController.gitlabController.createNewPages(i,a,h);case 2:d=c.sent,d.status?("has already been taken"===d.data.message.name?b.flash("error","Der Projektname '"+i.getName()+"' ist bereits vergeben, bitte w\xE4hlen Sie einen anderen Namen."):b.flash("error","Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.\xA0"),b.redirect("/account/newInformation")):(b.flash("success","Ihre Webseite wurde erstellt, aber noch nicht ver\xF6ffentlicht. Um Ihre Webseite endg\xFCltig zu ver\xF6ffentlichen, schlie\xDFen Sie die Einrichtung gem\xE4\xDF unten stehender Anleitung ab."),b.redirect("/account/updateInformation?id="+(d.id+"")));case 4:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}()],function(b){null!=b&&console.log(b),a.files&&_fs["default"].unlink(j,function(a){null!=a&&console.log(a)})})):(b.flash("error","Bitte geben Sie die ben\xF6tigten Daten ein"),b.redirect("/account/newInformation"));case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.get("/updateInformation_DEACTIVATED",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var f,g,h;return _regeneratorRuntime().wrap(function i(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=19;break;case 4:return c.next=6,e(a.user.email);case 6:if(f=c.sent,null!=f){c.next=11;break}b.redirect("/login"),c.next=19;break;case 11:if(a.query.id){c.next=15;break}b.redirect("/account/services"),c.next=19;break;case 15:return c.next=17,_gitlabController.gitlabController.getProjectById(a.query.id);case 17:g=c.sent,g?g.owner?g.owner.id===f.getGitlabUserId()?(h=new _website.Website(f.getGitlabUserId(),g.name,g.description,a.query.id,g.avatar_url,g.path_with_namespace),b.render(d+"/account/updateInformation",{user:f,information:h})):(console.log(" ========= Access denied: Not your project"),b.redirect("/account/services")):(console.log(" ========= Project cannot be accessed, since it does not have an owner"),b.redirect("/account/services")):(console.log(" ========= Error or no project found"),b.redirect("/account/services"));case 19:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a.post("/updateInformation_DEACTIVATED",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,f,g,h,i;return _regeneratorRuntime().wrap(function j(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case 4:return c.next=6,e(a.user.email);case 6:d=c.sent,null==d?b.redirect("/login"):a.body.name||a.body.description?(f=a.body.name.toLowerCase().replace(/\s/g,"-"),g=a.body.description,h=new _website.Website(d.getGitlabUserId(),f,g,a.query.id),_async["default"].waterfall([function(b){a.files?(i=a.files.logo,i.mv(logoDir+(i.name+""),function(a){i=logoDir+(i.name+""),b(a,i)})):b(null,i)},/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a){var d;return _regeneratorRuntime().wrap(function e(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,_gitlabController.gitlabController.updateProject(h,a);case 2:d=c.sent,d.status?"has already been taken"===d.data.message.name?b.flash("error","Der Projektname '"+(f+"' ist bereits vergeben, bitte w\xE4hlen Sie einen anderen Namen.")):b.flash("error","Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.\xA0"):(h.setLogo(d.avatar_url),h.setPath(d.path),b.flash("success","Ihre Website wurde aktualisiert")),b.redirect("/account/updateInformation?id="+(h.getId()+""));case 5:case"end":return c.stop();}},c)}));return function(b){return a.apply(this,arguments)}}()],function(a){null!=a&&console.log(a),i&&_fs["default"].unlink(i,function(a){null!=a&&console.log(a)})})):(b.flash("error","Bitte geben Sie die ben\xF6tigten Daten ein"),b.redirect("/account/updateInformation"));case 8:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}()),a["delete"]("/deleteProject_DEACTIVATED",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function c(a,b){var d,f,g,h;return _regeneratorRuntime().wrap(function i(c){for(;1;)switch(c.prev=c.next){case 0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=33;break;case 4:return c.next=6,e(a.user.email);case 6:if(d=c.sent,null!=d){c.next=11;break}b.redirect("/login"),c.next=33;break;case 11:if(f=a.body.id,!f){c.next=32;break}return c.next=15,_gitlabController.gitlabController.getProjectById(f);case 15:if(g=c.sent,g){c.next=20;break}console.log(" ========= Error or no project found"),c.next=32;break;case 20:if(g.owner){c.next=24;break}console.log(" ========= Project cannot be accessed, since it does not have an owner"),c.next=32;break;case 24:if(g.owner.id===d.getGitlabUserId()){c.next=28;break}console.log(" ========= Access denied: Not your project"),c.next=32;break;case 28:return c.next=30,_gitlabController.gitlabController.deleteProjectById(f);case 30:h=c.sent,h||b.flash("error","Project cannot be deleted. Please try again.");case 32:b.redirect("/account/services");case 33:case"end":return c.stop();}},c)}));return function(b,c){return a.apply(this,arguments)}}())};
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment