Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
When Meet - Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websystem2023-2
When Meet - Backend
Commits
73c06f81
Commit
73c06f81
authored
1 year ago
by
Wo-ogie
Browse files
Options
Downloads
Patches
Plain Diff
refactor: cookie-session 로그인 방식으로 수정
parent
159a6944
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controllers/meeting.js
+5
-27
5 additions, 27 deletions
controllers/meeting.js
middlewares/auth.js
+4
-7
4 additions, 7 deletions
middlewares/auth.js
with
9 additions
and
34 deletions
controllers/meeting.js
+
5
−
27
View file @
73c06f81
...
...
@@ -57,33 +57,11 @@ async function validatePasswordIsMatched(requestPassword, exPassword) {
}
}
function
setParticipantDataToCookie
(
req
,
res
,
participant
)
{
const
cookieName
=
'
participantData
'
;
const
cookieOptions
=
{
httpOnly
:
true
,
signed
:
true
,
function
storeParticipantDataToSession
(
req
,
res
,
participant
)
{
req
.
session
.
participant
=
{
meetingId
:
participant
.
MeetingId
,
participantId
:
participant
.
id
,
};
const
existCookie
=
req
.
signedCookies
.
participantData
||
null
;
if
(
existCookie
)
{
res
.
clearCookie
(
cookieName
,
JSON
.
stringify
({
meetingId
:
existCookie
.
meetingId
,
participantId
:
existCookie
.
participantId
,
}),
cookieOptions
,
);
}
res
.
cookie
(
cookieName
,
JSON
.
stringify
({
meetingId
:
participant
.
MeetingId
,
participantId
:
participant
.
id
,
}),
cookieOptions
,
);
}
exports
.
createMeeting
=
async
(
req
,
res
,
next
)
=>
{
...
...
@@ -131,7 +109,7 @@ exports.entry = async (req, res, next) => {
participant
.
password
,
);
}
s
e
tParticipantDataTo
Cookie
(
req
,
res
,
participant
);
st
ore
ParticipantDataTo
Session
(
req
,
res
,
participant
);
return
res
.
status
(
204
).
end
();
}
catch
(
error
)
{
return
next
(
error
);
...
...
This diff is collapsed.
Click to expand it.
middlewares/auth.js
+
4
−
7
View file @
73c06f81
function
parseParticipantData
(
req
,
res
,
next
)
{
let
participantData
=
null
;
if
(
req
.
signedCookies
.
participantData
)
{
participantData
=
JSON
.
parse
(
req
.
signedCookies
.
participantData
);
}
function
getParticipantDataFromSession
(
req
,
res
,
next
)
{
const
participantData
=
req
.
session
.
participant
;
if
(
!
participantData
)
{
const
error
=
new
Error
(
'
인증 권한이 없습니다.
'
);
error
.
status
=
401
;
...
...
@@ -12,7 +9,7 @@ function parseParticipantData(req, res, next) {
}
exports
.
isAuthenticated
=
(
req
,
res
,
next
)
=>
{
const
participantData
=
parse
ParticipantData
(
req
,
res
,
next
);
const
participantData
=
get
ParticipantData
FromSession
(
req
,
res
,
next
);
if
(
participantData
.
meetingId
!==
req
.
params
.
meetingId
)
{
const
error
=
new
Error
(
'
접근 권한이 없습니다.
'
);
error
.
status
=
401
;
...
...
@@ -23,6 +20,6 @@ exports.isAuthenticated = (req, res, next) => {
};
exports
.
getLoggedInParticipantId
=
(
req
,
res
,
next
)
=>
{
const
participantData
=
parse
ParticipantData
(
req
,
res
,
next
);
const
participantData
=
get
ParticipantData
FromSession
(
req
,
res
,
next
);
return
participantData
?.
participantId
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment