"use strict";function_typeof(a){"@babel/helpers - typeof";return_typeof="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(a){returntypeofa}:function(a){returna&&"function"==typeofSymbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeofa},_typeof(a)}var_fs=_interopRequireDefault(require("fs")),_async=_interopRequireDefault(require("async")),_bcryptjs=_interopRequireDefault(require("bcryptjs")),passportSaml=_interopRequireWildcard(require("passport-saml")),_dbconn=require("../config/dbconn"),_dbController=require("../controller/dbController"),_gitlabController=require("../controller/gitlabController"),_const=require("../config/const"),_mailer=require("../config/mailer"),_user=require("../classes/user"),_website=require("../classes/website"),_repo=require("../classes/repo");function_getRequireWildcardCache(a){if("function"!=typeofWeakMap)returnnull;varb=newWeakMap,c=newWeakMap;return(_getRequireWildcardCache=function(a){returna?c:b})(a)}function_interopRequireWildcard(a,b){if(!b&&a&&a.__esModule)returna;if(null===a||"object"!==_typeof(a)&&"function"!=typeofa)return{default:a};varc=_getRequireWildcardCache(b);if(c&&c.has(a))returnc.get(a);vard={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(varfina)if("default"!=f&&Object.prototype.hasOwnProperty.call(a,f)){varg=e?Object.getOwnPropertyDescriptor(a,f):null;g&&(g.get||g.set)?Object.defineProperty(d,f,g):d[f]=a[f]}returnd["default"]=a,c&&c.set(a,d),d}function_interopRequireDefault(a){returna&&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 */functiona(a,b,c){returnObject.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}functionb(a,b,e,f){varg=b&&b.prototypeinstanceofd?b:d,h=Object.create(g.prototype),j=newl(f||[]);returnh._invoke=function(a,b,d){vare="suspendedStart";returnfunction(f,g){if("executing"===e)thrownewError("Generator is already running");if("completed"===e){if("throw"===f)throwg;returnn()}for(d.method=f,d.arg=g;;){varh=d.delegate;if(h){varj=i(h,d);if(j){if(j===v)continue;returnj}}if("next"===d.method)d.sent=d._sent=d.arg;elseif("throw"===d.method){if("suspendedStart"===e)throwe="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";vark=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}functionc(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}functiond(){}functione(){}functionf(){}functiong(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){returnthis._invoke(c,a)})})}functionh(a,b){functiond(e,f,g,h){vari=c(a[e],a,f);if("throw"!==i.type){varj=i.arg,k=j.value;returnk&&"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){returnd("throw",a,g,h)})}h(i.arg)}vare;this._invoke=function(a,c){functionf(){returnnewb(function(b,e){d(a,c,b,e)})}returne=e?e.then(f,f):f()}}functioni(a,b){vard=a.iterator[b.method];if(void0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void0,i(a,b),"throw"===b.method))returnv;b.method="throw",b.arg=newTypeError("The iterator does not provide a 'throw' method")}returnv}vare=c(d,a.iterator,b.arg);if("throw"===e.type)returnb.method="throw",b.arg=e.arg,b.delegate=null,v;varf=e.arg;returnf?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void0),b.delegate=null,v):f:(b.method="throw",b.arg=newTypeError("iterator result is not an object"),b.delegate=null,v)}functionj(a){varb={tryLoc:a[0]};1ina&&(b.catchLoc=a[1]),2ina&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}functionk(a){varb=a.completion||{};b.type="normal",deleteb.arg,a.completion=b}functionl(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}functionm(a){if(a){varb=a[s];if(b)returnb.call(a);if("function"==typeofa.next)returna;if(!isNaN(a.length)){varc=-1,d=functionb(){for(;++c<a.length;)if(q.call(a,c))returnb.value=a[c],b.done=!1,b;returnb.value=void0,b.done=!0,b};returnd.next=d}}return{next:n}}functionn(){return{value:void0,done:!0}}_regeneratorRuntime=function(){returno};varo={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeofSymbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){returna[b]=c}}o.wrap=b;varv={},w={};a(w,s,function(){returnthis});varx=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);varz=f.prototype=d.prototype=Object.create(w);returne.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){varb="function"==typeofa&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){returnObject.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(){returnthis}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void0===f&&(f=Promise);varg=newh(b(a,c,d,e),f);returno.isGeneratorFunction(c)?g:g.next().then(function(a){returna.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){returnthis}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){varb=[];for(varcina)b.push(c);returnb.reverse(),functionc(){for(;b.length;){vard=b.pop();if(dina)returnc.value=d,c.done=!1,c}returnc.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:functionreset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void0,this.done=!1,this.delegate=null,this.method="next",this.arg=void0,this.tryEntries.forEach(k),!a)for(varbinthis)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void0)},stop:functionstop(){this.done=!0;vara=this.tryEntries[0].completion;if("throw"===a.type)throwa.arg;returnthis.rval},dispatchException:functiondispatchException(a){functionb(b,d){returnf.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void0),!!d}if(this.done)throwa;for(varc=this,d=this.tryEntries.length-1;0<=d;--d){vare=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)returnb("end");if(e.tryLoc<=this.prev){varg=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)returnb(e.catchLoc,!0);if(this.prev<e.finallyLoc)returnb(e.finallyLoc)}elseif(!g){if(!h)thrownewError("try statement without catch or finally");if(this.prev<e.finallyLoc)returnb(e.finallyLoc)}elseif(this.prev<e.catchLoc)returnb(e.catchLoc,!0)}}},abrupt:functionabrupt(a,b){for(varc,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){vare=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);varf=e?e.completion:{};returnf.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:functioncomplete(a,b){if("throw"===a.type)throwa.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:functionfinish(a){for(varb,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)returnthis.complete(b.completion,b.afterLoc),k(b),v},catch:function_catch(a){for(varb,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){vard=b.completion;if("throw"===d.type){vare=d.arg;k(b)}returne}thrownewError("illegal catch attempt")},delegateYield:functiondelegateYield(a,b,c){returnthis.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void0),v}},o}functionasyncGeneratorStep(a,b,c,d,e,f,g){try{varh=a[f](g),i=h.value}catch(a){returnvoidc(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function_asyncToGenerator(a){returnfunction(){varb=this,c=arguments;returnnewPromise(function(d,e){functionf(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}functiong(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}varh=a.apply(b,c);f(void0)})}}varSamlStrategy=passportSaml.Strategy,saltRounds=10,salt=64,logoDir="public/upload/",defaultLogo="public/default/logo.png";module.exports=function(a,b,c,d){// ======== APP ROUTES - ACCOUNT ====================
functione(){returnf.apply(this,arguments)}functionf(){returnf=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionb(a){varc,d,e;return_regeneratorRuntime().wrap(functionf(b){for(;1;)switch(b.prev=b.next){case0:returnb.next=2,_dbController.dbController.getUserByEmail(a);case2:if(c=b.sent,c){b.next=8;break}returnconsole.log("no user found"),b.abrupt("return",null);case8:returnd=new_user.User(c.id,a,c.salutation,c.title,c.firstname,c.lastname,c.industry,c.organisation,c.speciality,c.m4lab_idp,c.verificationStatus),b.next=11,_dbController.dbController.getGitlabId(d.id);case11:returne=b.sent,e&&d.setGitlabUserId(e),b.abrupt("return",d);case14:case"end":returnb.stop();}},b)})),f.apply(this,arguments)}c.serializeUser(function(a,b){b(null,a)}),c.deserializeUser(function(a,b){b(null,a)});varg=newSamlStrategy({// URL that goes from the Identity Provider -> Service Provider
callbackUrl:b.passport.saml.path,// Base address to call logout requests
logoutUrl:b.passport.saml.logoutUrl,entryPoint:b.passport.saml.entryPoint,issuer:b.passport.saml.issuer,identifierFormat:void0,// Service Provider private key
decryptionPvk:_fs["default"].readFileSync(__dirname+"/cert/key.pem","utf8"),// Service Provider Certificate
privateKey:_fs["default"].readFileSync(__dirname+"/cert/key.pem","utf8"),// Identity Provider's public key
// ============= 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");varc=g.generateServiceProviderMetadata(_fs["default"].readFileSync(__dirname+"/cert/cert.pem","utf8"));b.status(200).send(c)}),a.get("/",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){varf;return_regeneratorRuntime().wrap(functiong(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case4:returnc.next=6,e(a.user.email);case6: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});case8:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a.get("/login",c.authenticate(b.passport.strategy,{successRedirect:"/",failureRedirect:"/login"})),a.get("/logout",function(a,b){returnnull==a.user?b.redirect("/"):(a.user.nameID=a.user.id,a.user.nameIDFormat=a.user.idFormat,g.logout(a,function(c,d){returna.logout(),a.session&&a.session.destroy(function(a){if(a)returnconsole.log(a)}),b.redirect(d)}))}),a.get("/profile",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){varf;return_regeneratorRuntime().wrap(functiong(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case4:returnc.next=6,e(a.user.email);case6:f=c.sent,null==f?b.redirect("/account/"):1===f.getVerificationStatus()?b.render(d+"/account/profile",{user:f}):b.redirect("/account/");case8:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a.get("/services",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){varf,g,h,i,j,k,l,m,n;return_regeneratorRuntime().wrap(functiono(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=45;break;case4:returnc.next=6,e(a.user.email);case6:if(f=c.sent,null!=f){c.next=11;break}b.redirect("/account/"),c.next=45;break;case11:if(1===f.getVerificationStatus()){c.next=15;break}b.redirect("/account/"),c.next=45;break;case15:if(g=[],h=[],!f.getGitlabUserId()){c.next=41;break}returnc.next=20,_gitlabController.gitlabController.getUserProjects(f.getGitlabUserId());case20:if(i=c.sent,!i){c.next=38;break}c.t0=_regeneratorRuntime().keys(i);case23: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}returnc.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);case29:c.t3=c.sent,k={projectInformation:c.t2,pipelineStatus:c.t3},h.push(k),c.next=36;break;case34: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);case36:c.next=23;break;case38:b.render(d+"/account/services",{user:f,gitlabRepos:g,gitlabPages:h}),c.next=45;break;case41:returnc.next=43,_gitlabController.gitlabController.getUserByEmail(f.getEmail());case43: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});case45:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a.get("/security",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){varf;return_regeneratorRuntime().wrap(functiong(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case4:returnc.next=6,e(a.user.email);case6:f=c.sent,null==f?b.redirect("/account/"):1===f.getVerificationStatus()&&1===f.getIdpStatus()?b.render(d+"/account/security",{user:f}):b.redirect("/account/");case8:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a.post("/updateProfile",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){vard,f,g;return_regeneratorRuntime().wrap(functionh(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=17;break;case4:returnc.next=6,e(a.user.email);case6:if(d=c.sent,null!=d){c.next=11;break}b.redirect("/account/"),c.next=17;break;case11:returnf={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);case14: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");case17:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a.post("/changePwd",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){varf,g,h,i;return_regeneratorRuntime().wrap(functionj(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case4:returnc.next=6,e(a.user.email);case6: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}));vare=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(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functiond(a,c){vare,g;return_regeneratorRuntime().wrap(functiond(a){for(;1;)switch(a.prev=a.next){case0:returne={password:c,user_id:f.getId()},a.next=3,_dbController.dbController.updateCredential(e);case3: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");case6:case"end":returna.stop();}},d)}));returnfunction(b,c){returna.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"))})}));case8:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a.get("/resendVerificationEmail",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functiond(a,c){varf,g,h,i;return_regeneratorRuntime().wrap(functionj(d){for(;1;)switch(d.prev=d.next){case0:if(a.isAuthenticated){d.next=4;break}c.redirect("/login"),d.next=15;break;case4:returnd.next=6,e(a.user.email);case6:if(f=d.sent,null!=f){d.next=11;break}c.redirect("/login"),d.next=15;break;case11:returnd.next=13,_dbController.dbController.getVerificationTokenByUserId(f.id);case13: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)throwconsole.log("cannot send email"),a}),c.send(!0)):c.send(!1);case15:case"end":returnd.stop();}},d)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a.get("/newInformation",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){varf,g;return_regeneratorRuntime().wrap(functionh(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=15;break;case4:returnc.next=6,e(a.user.email);case6:if(f=c.sent,null!=f){c.next=11;break}b.redirect("/login"),c.next=15;break;case11:returnc.next=13,_gitlabController.gitlabController.getUserByEmail(f.getEmail());case13:g=c.sent,g?b.render(d+"/account/newInformation",{user:f,gitlabUsername:g.username}):b.redirect("/account/services");case15:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a.post("/newInformation",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){vard,f,g,h,i,j;return_regeneratorRuntime().wrap(functionk(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case4:returnc.next=6,e(a.user.email);case6: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(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a){vard;return_regeneratorRuntime().wrap(functione(c){for(;1;)switch(c.prev=c.next){case0:returnc.next=2,_gitlabController.gitlabController.createNewPages(i,a,h);case2: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+"")));case4:case"end":returnc.stop();}},c)}));returnfunction(b){returna.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"));case8:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a.get("/updateInformation",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){varf,g,h;return_regeneratorRuntime().wrap(functioni(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=19;break;case4:returnc.next=6,e(a.user.email);case6:if(f=c.sent,null!=f){c.next=11;break}b.redirect("/login"),c.next=19;break;case11:if(a.query.id){c.next=15;break}b.redirect("/account/services"),c.next=19;break;case15:returnc.next=17,_gitlabController.gitlabController.getProjectById(a.query.id);case17: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"));case19:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a.post("/updateInformation",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){vard,f,g,h,i;return_regeneratorRuntime().wrap(functionj(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=8;break;case4:returnc.next=6,e(a.user.email);case6: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(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a){vard;return_regeneratorRuntime().wrap(functione(c){for(;1;)switch(c.prev=c.next){case0:returnc.next=2,_gitlabController.gitlabController.updateProject(h,a);case2: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()+""));case5:case"end":returnc.stop();}},c)}));returnfunction(b){returna.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"));case8:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}()),a["delete"]("/deleteProject",/*#__PURE__*/function(){vara=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionc(a,b){vard,f,g,h;return_regeneratorRuntime().wrap(functioni(c){for(;1;)switch(c.prev=c.next){case0:if(a.isAuthenticated()){c.next=4;break}b.redirect("/login"),c.next=33;break;case4:returnc.next=6,e(a.user.email);case6:if(d=c.sent,null!=d){c.next=11;break}b.redirect("/login"),c.next=33;break;case11:if(f=a.body.id,!f){c.next=32;break}returnc.next=15,_gitlabController.gitlabController.getProjectById(f);case15:if(g=c.sent,g){c.next=20;break}console.log(" ========= Error or no project found"),c.next=32;break;case20:if(g.owner){c.next=24;break}console.log(" ========= Project cannot be accessed, since it does not have an owner"),c.next=32;break;case24:if(g.owner.id===d.getGitlabUserId()){c.next=28;break}console.log(" ========= Access denied: Not your project"),c.next=32;break;case28:returnc.next=30,_gitlabController.gitlabController.deleteProjectById(f);case30:h=c.sent,h||b.flash("error","Project cannot be deleted. Please try again.");case32:b.redirect("/account/services");case33:case"end":returnc.stop();}},c)}));returnfunction(b,c){returna.apply(this,arguments)}}())};