Showing
1 changed file
with
9 additions
and
4 deletions
... | @@ -13,6 +13,8 @@ var userId = 'test'; | ... | @@ -13,6 +13,8 @@ var userId = 'test'; |
13 | var userPass = '1234'; | 13 | var userPass = '1234'; |
14 | 14 | ||
15 | app.get('/login/:userId/password/:password', function (req, res) { | 15 | app.get('/login/:userId/password/:password', function (req, res) { |
16 | + // users 배열에서 찾도록 수정해야 함 | ||
17 | + // admin 여부를 지원할 수 있도록 수정해야 함 | ||
16 | if (req.params.userId == userId && req.params.password == userPass) { | 18 | if (req.params.userId == userId && req.params.password == userPass) { |
17 | req.session.userId = userId; | 19 | req.session.userId = userId; |
18 | } | 20 | } |
... | @@ -23,19 +25,22 @@ app.get('/logout/:userId', function (req, res) { | ... | @@ -23,19 +25,22 @@ app.get('/logout/:userId', function (req, res) { |
23 | // Logout | 25 | // Logout |
24 | req.session.userId = null; | 26 | req.session.userId = null; |
25 | res.send("LogOut"); | 27 | res.send("LogOut"); |
26 | - | 28 | + |
27 | }); | 29 | }); |
28 | 30 | ||
29 | var auth = function (req, res, next) { | 31 | var auth = function (req, res, next) { |
30 | // Session Check | 32 | // Session Check |
31 | - if (req.session.userId != null) | 33 | + if (req.session.userId != null) |
32 | next(); | 34 | next(); |
33 | else | 35 | else |
34 | res.send("Error"); | 36 | res.send("Error"); |
35 | - | 37 | + |
36 | }; | 38 | }; |
37 | app.get('/user/:userId', auth,function (req, res) { | 39 | app.get('/user/:userId', auth,function (req, res) { |
38 | // get User Information | 40 | // get User Information |
39 | res.send("OK"); | 41 | res.send("OK"); |
40 | -}); | 42 | +}); |
43 | + | ||
44 | +// 사용자 추가 시에 admin 여부도 추가해야 함 | ||
45 | + | ||
41 | var server = app.listen(80); | 46 | var server = app.listen(80); | ... | ... |
-
Please register or login to post a comment