Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김대철
/
CafeRecommend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
최정민
2021-05-11 07:15:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
20b74c414ddf6af9e2ac4fcbd3f9b180de9fe8d8
20b74c41
1 parent
3762470f
FEAT : 2차로그인 기능추가
session-file-store를 이용하여 회원가입 진행 -
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
4 deletions
package-lock.json
package.json
routes/index.js
sessions/MEbzXm6yVZ3x71k39o7JtR0-SirVibPV.json
views/login.ejs
package-lock.json
View file @
20b74c4
This diff is collapsed. Click to expand it.
package.json
View file @
20b74c4
...
...
@@ -10,8 +10,10 @@
"debug"
:
"~2.6.9"
,
"ejs"
:
"^3.1.6"
,
"express"
:
"^4.16.4"
,
"express-session"
:
"^1.17.1"
,
"google-auth-library"
:
"^7.0.4"
,
"http-errors"
:
"~1.6.3"
,
"morgan"
:
"~1.9.1"
"morgan"
:
"~1.9.1"
,
"session-file-store"
:
"^1.5.0"
}
}
...
...
routes/index.js
View file @
20b74c4
...
...
@@ -3,6 +3,14 @@ var router = express.Router();
var
{
OAuth2Client
}
=
require
(
'google-auth-library'
);
var
CLIENT_ID
=
"94679084723-s5f0686p2porp9mkakrp1p89a48n24nj.apps.googleusercontent.com"
var
client
=
new
OAuth2Client
(
CLIENT_ID
);
var
session
=
require
(
'express-session'
);
var
FileStore
=
require
(
'session-file-store'
)(
session
);
router
.
use
(
session
({
secret
:
'209'
,
// 암호화
resave
:
false
,
saveUninitialized
:
true
,
store
:
new
FileStore
()
}))
/* GET home page. */
router
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
...
...
@@ -30,7 +38,16 @@ router.post('/index', (req, res) => {
router
.
get
(
'/login'
,
checkAuthenticated
,
(
req
,
res
)
=>
{
let
user
=
req
.
user
;
res
.
render
(
'login'
,
{
user
})
req
.
session
.
user
=
user
;
res
.
render
(
'login'
,
{
user
:
req
.
session
.
user
})
});
router
.
post
(
'/login'
,(
req
,
res
)
=>
{
console
.
log
(
req
.
body
.
nickname
);
console
.
log
(
req
.
body
.
age
);
console
.
log
(
req
.
body
.
gender
);
return
res
.
render
(
'login'
,
{
user
:
req
.
session
.
user
})
});
module
.
exports
=
router
;
...
...
@@ -58,7 +75,7 @@ function checkAuthenticated(req, res, next){
next
();
})
.
catch
(
err
=>
{
res
.
redirect
(
'/
login
'
)
res
.
redirect
(
'/
index
'
)
})
}
\ No newline at end of file
...
...
sessions/MEbzXm6yVZ3x71k39o7JtR0-SirVibPV.json
0 → 100644
View file @
20b74c4
{
"cookie"
:{
"originalMaxAge"
:
null
,
"expires"
:
null
,
"httpOnly"
:
true
,
"path"
:
"/"
},
"__lastAccess"
:
1620684562564
,
"user"
:{
"name"
:
"최정민[학생](소프트웨어융합대학 컴퓨터공학과)"
,
"email"
:
"cjm2021401@khu.ac.kr"
,
"picture"
:
"https://lh3.googleusercontent.com/a/AATXAJzFD3R6CaL2NpysVrfvdGqcQ83vh_wpbN_5hj-0=s96-c"
}}
\ No newline at end of file
views/login.ejs
View file @
20b74c4
...
...
@@ -8,8 +8,22 @@
</head>
<body>
<a
href=
"/index"
onclick=
"signOut();"
>
Sign Out
</a>
<h1>
Hi
<
%= user.name %>
</h1>
<form
method=
"post"
>
NickName:
<br>
<input
type=
"text"
name=
"nickname"
value=
"MickeyMouse"
><br>
Age:
<br>
<input
type=
"text"
name=
"age"
value=
"19"
><br><br>
<input
type=
"radio"
id=
"male"
name=
"gender"
value=
"male"
>
<label
for=
"male"
>
Male
</label><br>
<input
type=
"radio"
id=
"female"
name=
"gender"
value=
"female"
>
<label
for=
"female"
>
Female
</label><br>
<input
type=
"submit"
value=
"Submit"
>
</form>
<a
href=
"/index"
onclick=
"signOut();"
>
Sign Out
</a>
</body>
<script>
...
...
Please
register
or
login
to post a comment