Skip to content

Commit d1af42c

Browse files
committed
Fix views of header and add logout button
1 parent 5f61244 commit d1af42c

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

controllers/user.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ router.get('/', login, handler_index);
3232
router.post('/printCode', login, handler_post_printCode);
3333

3434
function handler_index (req,res){
35-
return res.render('layout', {
36-
ip: getReqIp(req)
35+
return res.render('home', {
36+
ip: getReqIp(req),
37+
username: req.session.username
3738
});
3839
}
3940

middlewares/login.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = function(req, res, next) {
22
if ( !req.session || !req.session.login ) {
3-
return res.redirect("/login");
3+
return res.redirect("/user/login");
44
}
55
next();
66
}

views/home.pug

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@ extends layout.pug
22

33

44
block content
5-
.row
6-
.col
7-
h1 Print Server
8-
.col.text-right
9-
h3= ip
105
form(action='/printCode', method='post')
116
.row
127
.col
138
.form-group
14-
label(for='code') Code
15-
textarea#code.form-control(name='code', style="height:500px;")
9+
label(for='code')
10+
textarea#code.form-control(name='code', style="height:500px;") Paste code here
1611
.row
1712
.col.text-center
1813
input.btn.btn-primary.mr-1.disableOnClick(type='submit', value='Print')

views/login.pug

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extends layout.pug
33
block content
44
.row
55
.col-6.offset-3
6-
form(action='/login', method='post')
6+
form(action='/user/login', method='post')
77
.form-group
88
label(for="username") User Name
99
input(placeholder="Enter Username", name="username").form-control#username

views/partials/header.pug

+7-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
h1.text-center Print Server
1+
.row.p-2
2+
.col-4
3+
span= username
4+
.col-4
5+
h1.text-center Print Server
6+
.col.text-right
7+
a(href="/user/logout") Logout

0 commit comments

Comments
 (0)