diff --git a/index.js b/index.js
index a82d855..3e002f0 100644
--- a/index.js
+++ b/index.js
@@ -36,17 +36,25 @@ function authNoRedirectHandler(req, res, next){
} else if(data.user){ // If authcookie is valid
req.user = data.user; // Set user to data.user
mysql_handler.con.query(`SELECT * FROM users WHERE id = "${req.user}"`, (err, result) => { // Get user from database
+
if(err) console.log(err);
let user = JSON.parse(JSON.stringify(result))[0]; // Parse user from database
- if(user.id){
- // Set user to req.user
- req.isAdmin = user.isAdmin;
- req.username = user.username;
- req.firstname = user.firstname;
- req.lastname = user.lastname;
- req.email = user.email;
+ console.log("Moin3")
+ try{
+ if(user.id){
+ console.log("Moin4")
+ // Set user to req.user
+ req.isAdmin = user.isAdmin;
+ req.username = user.username;
+ req.firstname = user.firstname;
+ req.lastname = user.lastname;
+ req.email = user.email;
+ }
+ }catch{
+ res.redirect('/logout')
+ return;
}
-
+ console.log("Moin5")
next(); // Continue to next handler
});
}
@@ -66,13 +74,16 @@ function authenticatedHandler(req, res, next){
req.user = data.user; // Set user to data.user
mysql_handler.con.query(`SELECT * FROM users LEFT JOIN userinfos ON users.id=userinfos.userId WHERE users.id = "${req.user}"`, (err, result) => { // Get user from database
if(err) console.log(err);
- let user = JSON.parse(JSON.stringify(result))[0]; // Parse user from database
- // Set user to req.user
- req.isAdmin = user.isAdmin;
- req.username = user.username;
- req.firstname = user.firstname;
- req.lastname = user.lastname;
- req.email = user.email;
+ if(result.length > 0){
+ let user = JSON.parse(JSON.stringify(result))[0]; // Parse user from database
+ // Set user to req.user
+ req.isAdmin = user.isAdmin;
+ req.username = user.username;
+ req.firstname = user.firstname;
+ req.lastname = user.lastname;
+ req.email = user.email;
+
+ }
next(); // Continue to next handler
});
}
diff --git a/static/css/account.css b/static/css/account.css
index 567f3f4..09719ba 100644
--- a/static/css/account.css
+++ b/static/css/account.css
@@ -2,10 +2,10 @@
display: block;
margin-left: auto;
margin-right: auto;
- width: 600px;
margin-top: 60px;
margin-bottom: 60px;
- border-bottom: 2px solid rgb(104, 117, 151);;
+ border-bottom: 2px solid rgb(104, 117, 151);
+ padding-left: 20px;
}
#account-info p{
@@ -22,7 +22,6 @@ h4{
display: block;
margin-left: auto;
margin-right: auto;
- width: 600px;
margin-top: 60px;
margin-bottom: 60px;
border-bottom: 2px solid rgb(104, 117, 151);;
diff --git a/static/css/style.css b/static/css/style.css
index 70c6a7d..1a25b05 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -30,7 +30,6 @@ h1, h2{
margin-right: auto;
width: 100%;
display:block;
- text-align: left;
}
.text-redirect{
diff --git a/views/account.ejs b/views/account.ejs
index 045bd7f..040d9df 100644
--- a/views/account.ejs
+++ b/views/account.ejs
@@ -6,41 +6,47 @@
<%- include('partials/header'); %>
- Ihr Konto
-
-
Persönliche Informationen
-
Vorname: <%= firstname %>
-
Nachname: <%= lastname %>
-
Benutzername: <%= username %>
-
E-Mail: <%= email.substring(0,email.length/3) %><% for(var i = 0; i < email.length - email.length/4; i++){ %>*<% } %>
-
-
-
-
-
Ihre Bestellungen
-
-
-
- | Bestellnummer |
- Produktname |
- Anzahl |
- Stückpreis |
- Gesamtpreis |
-
-
-
- <% for(var i = 0; i < orders.length; i++){ %>
+
+
Ihr Konto
+
+
Persönliche Informationen
+
Vorname: <%= firstname %>
+
Nachname: <%= lastname %>
+
Benutzername: <%= username %>
+
E-Mail: <%= email.substring(0,email.length/3) %><% for(var i = 0; i < email.length - email.length/4; i++){ %>*<% } %>
+
Adresse:
+
+
+
+
+
Ihre Bestellungen
+
+
- | <%= orders[i].id %> |
- <%= orders[i].name %> |
- <%= orders[i].quantity %> |
- <%= orders[i].price %> |
- <%= orders[i].price * orders[i].quantity%> € |
+ Bestellnummer |
+ Produktname |
+ Status |
+ Anzahl |
+ Stückpreis |
+ Gesamtpreis |
- <% } %>
-
-
+
+
+ <% for(var i = 0; i < orders.length; i++){ %>
+
+ | <%= orders[i].id %> |
+ <%= orders[i].name %> |
+ In Progress |
+ <%= orders[i].quantity %> |
+ <%= orders[i].price %> |
+ <%= orders[i].price * orders[i].quantity%> € |
+
+ <% } %>
+
+
+
+