Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebBack
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
websystem
WebBack
Commits
f201437a
Commit
f201437a
authored
3 months ago
by
tpgus2603
Browse files
Options
Downloads
Patches
Plain Diff
refactor: 로그인 처리방식 수정
parent
6e6a6531
No related branches found
Branches containing commit
No related tags found
1 merge request
!42
[#25] 배포코드 master브랜치로 이동
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
routes/auth.js
+18
-14
18 additions, 14 deletions
routes/auth.js
with
18 additions
and
14 deletions
routes/auth.js
+
18
−
14
View file @
f201437a
...
...
@@ -5,34 +5,38 @@ const router = express.Router();
// GET api/auth/login
router
.
get
(
'
/login
'
,
(
req
,
res
,
next
)
=>
{
// 프론트엔드에서 전달한 redirectUrl 가져오기
const
redirectUrl
=
req
.
query
.
redirectUrl
||
process
.
env
.
FRONTEND_URL
||
'
https://yanawa.shop
'
;
// redirectUrl 유효성 검증
// redirectUrl 세션에 저장
req
.
session
.
redirectUrl
=
redirectUrl
;
// Google OAuth 인증 시작
passport
.
authenticate
(
'
google
'
,
{
scope
:
[
'
profile
'
,
'
email
'
]
})(
req
,
res
,
next
);
});
router
.
get
(
'
/google/callback
'
,
passport
.
authenticate
(
'
google
'
,
{
failureRedirect
:
'
/auth/login
'
}),
(
req
,
res
)
=>
{
const
redirectUrl
=
req
.
session
.
redirectUrl
||
'
https://yanawa.shop
'
;
req
.
session
.
redirectUrl
=
null
;
const
redirectUrl
=
process
.
env
.
FRONT_URL
;
req
.
session
.
save
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
세션 저장 오류:
'
,
err
);
return
res
.
status
(
500
).
json
({
error
:
'
서버 오류
'
});
}
res
.
redirect
(
redirectUrl
);
});
}
);
// GET api/auth/logout
router
.
get
(
'
/logout
'
,
(
req
,
res
)
=>
{
if
(
req
.
session
)
{
req
.
session
.
destroy
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
세션 삭제 오류:
'
,
err
);
return
res
.
status
(
500
).
json
({
error
:
'
서버 오류
'
});
}
const
redirectUrl
=
process
.
env
.
FRONT_URL
;
res
.
redirect
(
redirectUrl
);
});
}
else
{
// 세션이 없는 경우에도 리다이렉트
const
redirectUrl
=
process
.
env
.
FRONT_URL
;
res
.
redirect
(
redirectUrl
);
}
});
module
.
exports
=
router
;
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