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-21 19:30:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c16e4e398929482a16a2641e8370839ae142aff6
c16e4e39
1 parent
e62ba81f
FIX : 오타수정
session file store정의부분 ; 제거 -
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
10 deletions
routes/index.js
sessions/RjC6-i4370iZsmzfcOEPHbT7yL9pcIDw.json
sessions/XTk9Iu_cq1WCRRi6ad5ecWT5XPCf6ARY.json
views/index.ejs
routes/index.js
View file @
c16e4e3
var
express
=
require
(
"express"
);
var
router
=
express
.
Router
();
var
request
=
require
(
"request"
);
//
var request = require("request");
var
bodyParser
=
require
(
"body-parser"
);
var
{
OAuth2Client
}
=
require
(
"google-auth-library"
);
var
querystring
=
require
(
"querystring"
);
//
var querystring = require("querystring");
var
CLIENT_ID
=
"94679084723-s5f0686p2porp9mkakrp1p89a48n24nj.apps.googleusercontent.com"
;
...
...
@@ -21,8 +21,7 @@ router.use(
resave
:
false
,
saveUninitialized
:
true
,
store
:
new
FileStore
(),
})
);
}))
var
connection
=
mysql
.
createConnection
({
host
:
"localhost"
,
user
:
"root"
,
...
...
@@ -49,6 +48,8 @@ router.post("/index", (req, res) => {
idToken
:
token
,
audience
:
CLIENT_ID
,
// Specify the CLIENT_ID of the app that accesses the backend
});
const
payload
=
ticket
.
getPayload
();
const
userid
=
payload
[
'sub'
]
}
verify
()
.
then
(()
=>
{
...
...
@@ -59,6 +60,8 @@ router.post("/index", (req, res) => {
});
router
.
get
(
"/login"
,
checkAuthenticated
,
(
req
,
res
)
=>
{
let
user
=
req
.
user
;
req
.
session
.
user
=
user
;
var
sql
=
"SELECT * FROM USER WHERE EMAIL=?"
;
var
parameter
=
[
req
.
session
.
user
.
email
];
connection
.
query
(
sql
,
parameter
,
function
(
err
,
row
)
{
...
...
@@ -124,7 +127,6 @@ module.exports = router;
function
checkAuthenticated
(
req
,
res
,
next
)
{
let
token
=
req
.
cookies
[
"session-token"
];
let
user
=
{};
async
function
verify
()
{
const
ticket
=
await
client
.
verifyIdToken
({
...
...
@@ -137,8 +139,7 @@ function checkAuthenticated(req, res, next) {
}
verify
()
.
then
(()
=>
{
req
.
session
.
user
.
name
=
user
.
name
;
req
.
session
.
user
.
email
=
user
.
email
;
req
.
user
=
user
;
next
();
})
.
catch
((
err
)
=>
{
...
...
sessions/RjC6-i4370iZsmzfcOEPHbT7yL9pcIDw.json
0 → 100644
View file @
c16e4e3
{
"cookie"
:{
"originalMaxAge"
:
null
,
"expires"
:
null
,
"httpOnly"
:
true
,
"path"
:
"/"
},
"__lastAccess"
:
1621534089028
,
"user"
:{
"name"
:
"최정민[학생](소프트웨어융합대학 컴퓨터공학과)"
,
"email"
:
"cjm2021401@khu.ac.kr"
}}
\ No newline at end of file
sessions/XTk9Iu_cq1WCRRi6ad5ecWT5XPCf6ARY.json
0 → 100644
View file @
c16e4e3
{
"cookie"
:{
"originalMaxAge"
:
null
,
"expires"
:
null
,
"httpOnly"
:
true
,
"path"
:
"/"
},
"__lastAccess"
:
1621592914035
,
"user"
:{
"name"
:
"최정민[학생](소프트웨어융합대학 컴퓨터공학과)"
,
"email"
:
"cjm2021401@khu.ac.kr"
,
"nickname"
:
"MickeyMouse"
,
"age"
:
"19"
,
"gender"
:
"male"
}}
\ No newline at end of file
views/index.ejs
View file @
c16e4e3
...
...
@@ -3,9 +3,9 @@
<head>
<meta
charset=
"UTF-8"
>
<script
src=
"https://apis.google.com/js/platform.js"
async
defer
></script>
<meta
name=
"google-signin-client_id"
content=
<%=d%
>
>
<meta
name=
"google-signin-client_id"
content=
"94679084723-s5f0686p2porp9mkakrp1p89a48n24nj.apps.googleusercontent.com"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
<
%= d%>
</title>
<title>
first
</title>
<link
rel=
'stylesheet'
href=
'/stylesheets/style.css'
/>
</head>
...
...
@@ -19,7 +19,7 @@
<script>
function
onSignIn
(
googleUser
)
{
var
id_token
=
googleUser
.
getAuthResponse
().
id_token
;
//
console.log(id_token);
console
.
log
(
id_token
);
var
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
'POST'
,
'/index'
);
xhr
.
setRequestHeader
(
'Content-Type'
,
'application/json'
);
...
...
Please
register
or
login
to post a comment