From 78329c243d9ad285cf1c998f285a5b65c8e6fa5a Mon Sep 17 00:00:00 2001 From: Rosanny Date: Tue, 21 Sep 2021 15:27:33 +0200 Subject: [PATCH 1/7] add customized error when user data is not found --- routes/account.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/routes/account.ts b/routes/account.ts index 68c3ca61..ce921c56 100644 --- a/routes/account.ts +++ b/routes/account.ts @@ -106,10 +106,14 @@ export = function (app:any, config:any, passport:any, lang:string) { res.redirect('/login') } else { let loggedInUser = await getLoggedInUserData(req.user.email) - - res.render(lang+'/account/home', { - user: loggedInUser - }); + if (!loggedInUser) { + console.error("user data is not found") + res.status(500).render(lang+'/500', { error: "Your data is not found. Please try again." }) + } else { + res.render(lang+'/account/home', { + user: loggedInUser + }); + } } }); -- GitLab From e00f0382427362076c437a86b3fb327723866c06 Mon Sep 17 00:00:00 2001 From: Wolfgang Knopki Date: Fri, 24 Sep 2021 10:50:40 +0200 Subject: [PATCH 2/7] pick connection from pool before transaction --- functions/methods.ts | 81 +++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/functions/methods.ts b/functions/methods.ts index cebfcb21..79416aee 100644 --- a/functions/methods.ts +++ b/functions/methods.ts @@ -3,62 +3,65 @@ import dbconn = require('../config/dbconn') var methods = { // ===================== user db ===================== registerNewUser: function(data:any, callback:any) { - dbconn.user.beginTransaction(function(err:any) { // START TRANSACTION - if (err) { throw err } - // insert profile - dbconn.user.query('INSERT INTO user SET ?', data.profile, function (err:any, results:any, fields:any) { - if (err) { - return dbconn.user.rollback(function() { - throw err - }); - } - let newUserId:number = results.insertId - // set password - var credentialData:any = { - user_id: newUserId, - password: data.password - } - dbconn.user.query('INSERT INTO credential SET ?', credentialData, function (err:any, results:any, fields:any) { + dbconn.user.getConnection(function(err:any, thisconn){ + thisconn.beginTransaction(function(err:any) { // START TRANSACTION + if (err) { throw err } + // insert profile + thisconn.query('INSERT INTO user SET ?', data.profile, function (err:any, results:any, fields:any) { if (err) { - return dbconn.user.rollback(function() { - throw err - }); + return thisconn.rollback(function() { + throw err + }); } - // set default user-project-role - var projectRoleData:any = { - project_id: 1, //M4_LAB - role_id: 2, // USER - user_id: newUserId + let newUserId:number = results.insertId + // set password + var credentialData:any = { + user_id: newUserId, + password: data.password } - dbconn.user.query('INSERT INTO user_project_role SET ?', projectRoleData, function (err:any, results:any, fields:any) { + thisconn.query('INSERT INTO credential SET ?', credentialData, function (err:any, results:any, fields:any) { if (err) { - return dbconn.user.rollback(function() { + return thisconn.rollback(function() { throw err }); } - // MLAB-129: INSERT verification token - let verificationData:any = { - user_id: newUserId, - token: data.verificationToken + // set default user-project-role + var projectRoleData:any = { + project_id: 1, //M4_LAB + role_id: 2, // USER + user_id: newUserId } - dbconn.user.query('INSERT INTO verification SET ?', verificationData, function (err:any, results:any, fields:any) { + thisconn.query('INSERT INTO user_project_role SET ?', projectRoleData, function (err:any, results:any, fields:any) { if (err) { - return dbconn.user.rollback(function() { + return thisconn.rollback(function() { throw err }); } - // COMMIT - dbconn.user.commit(function(err:any) { + // MLAB-129: INSERT verification token + let verificationData:any = { + user_id: newUserId, + token: data.verificationToken + } + thisconn.query('INSERT INTO verification SET ?', verificationData, function (err:any, results:any, fields:any) { if (err) { - return dbconn.user.rollback(function() { + return thisconn.rollback(function() { throw err - }) + }); } + // COMMIT + thisconn.commit(function(err:any) { + if (err) { + return thisconn.rollback(function() { + throw err + }) + } + }) }) }) - }) + }); }); - }); + callback(err) + }); callback(err) }) }, @@ -208,4 +211,4 @@ var methods = { } }; -export = methods \ No newline at end of file +export = methods -- GitLab From 63dcd5345484491780c5e33ee4396eb341f21d15 Mon Sep 17 00:00:00 2001 From: Wolfgang Knopki Date: Fri, 24 Sep 2021 11:13:32 +0200 Subject: [PATCH 3/7] fixed double callbacks causing ERR_HTTP_HEADERS_SENT --- functions/methods.ts | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/functions/methods.ts b/functions/methods.ts index 79416aee..f6a4eb59 100644 --- a/functions/methods.ts +++ b/functions/methods.ts @@ -60,7 +60,6 @@ var methods = { }) }); }); - callback(err) }); callback(err) }) @@ -165,27 +164,29 @@ var methods = { return null }, verifyUserAccount: function(userData:any, callback:any) { - dbconn.user.beginTransaction(function(err:any) { // START TRANSACTION - if (err) { throw err } - // update user status - dbconn.user.query('UPDATE user SET ? WHERE id =' +userData.id, userData, function (err:any, rows:any, fields:any) { - if (err) { - return dbconn.user.rollback(function() { throw err }) - } - // delete verification token - dbconn.user.query('DELETE FROM verification WHERE user_id = '+userData.id, function (err:any, rows:any, fields:any) { + dbconn.user.getConnection(function(err:any, thisconn){ + thisconn.beginTransaction(function(err:any) { // START TRANSACTION + if (err) { throw err } + // update user status + thisconn.query('UPDATE user SET ? WHERE id =' +userData.id, userData, function (err:any, rows:any, fields:any) { if (err) { - return dbconn.user.rollback(function() { throw err }) + return thisconn.rollback(function() { throw err }) } - // COMMIT - dbconn.user.commit(function(err:any) { + // delete verification token + thisconn.query('DELETE FROM verification WHERE user_id = '+userData.id, function (err:any, rows:any, fields:any) { if (err) { - return dbconn.user.rollback(function() { throw err }) + return thisconn.rollback(function() { throw err }) } + // COMMIT + thisconn.commit(function(err:any) { + if (err) { + return thisconn.rollback(function() { throw err }) + } + }) }) }) }) - callback(err) + callback(err) }) }, /* ===== GitLab ===== */ -- GitLab From 19179d554f86745531418be19d16bcf37bc11fef Mon Sep 17 00:00:00 2001 From: Rosanny Date: Tue, 19 Oct 2021 12:49:02 +0200 Subject: [PATCH 4/7] MLAB-603: fixing update profile --- views/DE/account/profile.pug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/DE/account/profile.pug b/views/DE/account/profile.pug index 8ab9bf55..3c109a51 100644 --- a/views/DE/account/profile.pug +++ b/views/DE/account/profile.pug @@ -49,7 +49,7 @@ html(lang="de") a(class="close", href="#", data-dismiss="alert", aria-label="close") × h3(class="pb-2") Mein Profil - form#profileForm(method="POST", action="/updateProfile") + form#profileForm(method="POST", action="/account/updateProfile") div(class="form-row") div(class='form-group col-md-2') label(for="title") Anrede -- GitLab From f8e832da4c59e6160712c5d1416a5d9442d52191 Mon Sep 17 00:00:00 2001 From: Rosanny Date: Tue, 19 Oct 2021 14:08:31 +0200 Subject: [PATCH 5/7] MLAB-602: fixing update password --- routes/account.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/account.ts b/routes/account.ts index ce921c56..f47a1ac4 100644 --- a/routes/account.ts +++ b/routes/account.ts @@ -286,7 +286,7 @@ export = function (app:any, config:any, passport:any, lang:string) { } }); - app.post('/account/changePwd', async function (req:any, res:any) { + app.post('/changePwd', async function (req:any, res:any) { if( !req.isAuthenticated() ) { res.redirect('/login') } else { -- GitLab From d85db2113c88f550a5a85341c5981a226ac217ae Mon Sep 17 00:00:00 2001 From: Rosanny Date: Tue, 19 Oct 2021 14:45:28 +0200 Subject: [PATCH 6/7] MLAB-607: fixing the broken link to delete a project --- views/DE/account/updateInformation.pug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/DE/account/updateInformation.pug b/views/DE/account/updateInformation.pug index 58cd8a42..130dd95e 100644 --- a/views/DE/account/updateInformation.pug +++ b/views/DE/account/updateInformation.pug @@ -130,7 +130,7 @@ html(lang="de") |

Sie sind dabei, diese Webseite, ihr Repositorium und alle zugehörigen Ressourcen, inklusive aller Inhalte, Bilder etc. endgültig zu löschen.

|

Sobald eine Webseite endgültig gelöscht ist, kann sie nicht wiederhergestellt werden. Diese Aktion kann nicht rückgängig gemacht werden.

div(class="modal-footer") - form(method="POST", action="/deleteProject?_method=DELETE", encType="multipart/form-data") + form(method="POST", action="/account/deleteProject?_method=DELETE", encType="multipart/form-data") input(name="id", value=information.id, type="hidden") button(type="button" class="btn btn-primary mx-2" data-dismiss="modal") Abbrechen, Webseite behalten button(type="submit" class="btn btn-danger") Ja, Webseite löschen -- GitLab From 66d2fd07bdc49f24693e06a7d920a9e054a9f08f Mon Sep 17 00:00:00 2001 From: Athanasios Date: Fri, 5 Nov 2021 10:05:19 +0100 Subject: [PATCH 7/7] Hide mobile menu in contact page --- views/DE/account/contact.pug | 2 ++ 1 file changed, 2 insertions(+) diff --git a/views/DE/account/contact.pug b/views/DE/account/contact.pug index 99c37ce9..d25a801d 100644 --- a/views/DE/account/contact.pug +++ b/views/DE/account/contact.pug @@ -6,6 +6,7 @@ html(lang="de") meta(name="viewport", content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no") link(rel="stylesheet", type="text/css", href="/css/bootstrap.min.css") link(rel="stylesheet", type="text/css", href="/css/m4lab.css") + link(rel="stylesheet", type="text/css", href="/css/m4lab-mobile.css") link(rel="stylesheet", type="text/css", href="/css/Contact-Form-Clean.css") link(rel="stylesheet", href="https://use.fontawesome.com/releases/v5.8.2/css/all.css", integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay", crossorigin="anonymous") body @@ -52,3 +53,4 @@ html(lang="de") script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous") // M4_LAB script(src="/js/headfoot.js") + script(src="/js/mobile.js") -- GitLab