Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정혜인
/
OSS
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Authored by
swjin
2019-11-08 09:22:32 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c37d9d67b3ff689d88c76ae955c70be5c26e18de
c37d9d67
1 parent
792014ea
Comment added
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
Experiments/experiments09/assignments/assignment02/app.js
Experiments/experiments09/assignments/assignment02/app.js
View file @
c37d9d6
...
...
@@ -13,6 +13,8 @@ var userId = 'test';
var
userPass
=
'1234'
;
app
.
get
(
'/login/:userId/password/:password'
,
function
(
req
,
res
)
{
// users 배열에서 찾도록 수정해야 함
// admin 여부를 지원할 수 있도록 수정해야 함
if
(
req
.
params
.
userId
==
userId
&&
req
.
params
.
password
==
userPass
)
{
req
.
session
.
userId
=
userId
;
}
...
...
@@ -23,19 +25,22 @@ app.get('/logout/:userId', function (req, res) {
// Logout
req
.
session
.
userId
=
null
;
res
.
send
(
"LogOut"
);
});
var
auth
=
function
(
req
,
res
,
next
)
{
// Session Check
if
(
req
.
session
.
userId
!=
null
)
if
(
req
.
session
.
userId
!=
null
)
next
();
else
res
.
send
(
"Error"
);
};
app
.
get
(
'/user/:userId'
,
auth
,
function
(
req
,
res
)
{
// get User Information
res
.
send
(
"OK"
);
});
});
// 사용자 추가 시에 admin 여부도 추가해야 함
var
server
=
app
.
listen
(
80
);
...
...
Please
register
or
login
to post a comment