-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[7주차] SNIFF 미션 제출합니다. #3
Open
oooppq
wants to merge
75
commits into
CEOS-Developers:main
Choose a base branch
from
team-acode:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 73 commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
8712e4d
init: create next app
oooppq d653601
init: 배포 자동화 설정
oooppq 03439ad
init: 의존성 추가
oooppq 3c6b4d6
init: 기본 컴포넌트 정리
oooppq 31a3550
init: 필수적인 컴포넌트 구성
oooppq d6aeedf
style: nav bar 스타일 적용
oooppq e4aff6c
chore: ceos indigo color tailwind에 등록
oooppq 5a24dac
refactor: nav bar 디자인 반응형으로 변경 및 이미지 사용방식 변경
oooppq a6f3ee9
style: 홈화면 스타일 적용
oooppq 93090a7
chore: nav bar height 고정
oooppq dbcd659
chore: hovering button text weight semibold 설정
oooppq bc45614
feat: navbar 라우팅 설정
oooppq 2eda40e
chore: pr template 추가
oooppq 8abd85e
Merge pull request #1 from oooppq/feature/home
oooppq 8154eae
feat: 로그인/회원가입시 navbar 보이지 않도록 함
oooppq 03a34f4
style: 회원가입 디자인 일부 적용 완료
oooppq d219b8c
style: 회원가입 기본 디자인 적용 완료
oooppq faa822e
style: 로그인 기본 디자인 적용 완료
oooppq 3f38d11
refactor: authInput 속성 변경
oooppq 1027993
feat: 로그인 로직 추가
oooppq d2f7c0c
feat: 유저 session 받아오는 api 구현
oooppq 5bf8d77
feat: csr용 유저 session 커스텀 훅 구현
oooppq 3136b80
feat: userInfo 타입 지정
oooppq 272d6b5
feat: jwt token expiration 구현
oooppq 04fc991
feat: 홈화면 로그인 여부에 따른 view 변화 적용
oooppq 38b161f
feat: navbar 로그인 상태 view 적용
oooppq f5e47f4
feat: 로그아웃 기능 구현
oooppq 14e6733
feat: 홈화면 로그인 여부에 따른 라우팅 차이 적용
oooppq 8995d34
feat: middleware를 통해 페이지 진입시 로그인 여부 검증
oooppq 6c2d7e3
style: 로그인/회원가입 input 디자인 조금 변경
oooppq a8a4812
feat: 로그인 페이지에 회원가입 버튼 추가
oooppq d2271a3
feat: 로그인 실패 관련 처리 구현
oooppq 6310452
feat: 회원가입 입력값 검증 기능 구현
oooppq b68c9ea
feat: 회원가입 중복아이디 이메일 처리 추가
oooppq 8fe9f47
feat: 회원가입 드롭타운 컴포넌트 구현
oooppq d7dc289
feat: 드롭다운 없애고 radio 박스로 변경
oooppq b423be9
feat: 파트/팀 선택 관련 기능 구현
oooppq c5a6179
chore: fetch 관련 사소한 타이핑들 수정
oooppq d0cb550
Merge pull request #2 from oooppq/feature/auth
oooppq 46eee16
feature:partvote 초기 설정
flowerseok ff85849
feat: partvote 페이지 초기완성
flowerseok 5636f54
feat: partvote 페이지 초기완성
flowerseok 84809c6
feat: 데모데이투표화면 구성
flowerseok e6a822a
feat: 데모데이 투표화면 구성
flowerseok 2ceff0e
chore: 자잘한 경로들 수정
flowerseok 22b7969
style: css 수정
flowerseok 208a8e3
style : css수정
flowerseok dfe2810
feat : api header추가
flowerseok 83251ec
feat: api header추가
flowerseok 31e30a6
chore: 자잘한 수정
flowerseok 3a41cf2
chore: header 추가
flowerseok 532fb4f
chore: 오타수정
flowerseok 7243f29
Merge pull request #3 from flowerseok/feature/demovote
oooppq 9613795
refactor: axios 삭제
oooppq 115c21b
refactor: 투표 결과 server-side component로 변경
oooppq e8d3e7a
chore: 타이포 수정 및 네비게이션 설정
oooppq f143feb
feat: 투표 완료시 투표여부 flag 업데이트
oooppq 27e105d
debug: 회원가입시 중복된 id/email 관련 오류 처리 에러 수정
oooppq 7d4cbae
feat: middleware 수정
oooppq 09de8d8
Merge pull request #4 from oooppq/chore
oooppq 06c23ee
style: 투표/결과 페이지 디자인 수정
oooppq da3171a
Merge pull request #5 from oooppq/feature/vote
oooppq 81e8465
hotfix: 파트장 투표결과 안내문구 삽입
oooppq 7389a8f
hotfix: 백엔드 파트장 투표 안되는 오류 해결 및 투표하기 여러번 클릭 방지
oooppq b9c00b8
hotfix: 로그인 한 사람은 모두 투표 결과 볼 수 있게 수정
oooppq a3265b3
hotfix: 모든 fetch 요청 no-cache로 변경
oooppq 0d5b49e
hotfix: 파트별 결과 볼 수 있도록 구현
oooppq 9f53be2
hotfix: 유저 이름 길면 navbar 줄바꿈 일어나는 문제 해결
oooppq 937f1c3
hotfix: 로그아웃 요청이 제대로 전달 안돼도 일단 로그아웃되도록 설정
oooppq 98f2e81
hotfix: 로그아웃 요청이 제대로 전달 안돼도 일단 로그아웃되고, 새로고침 되도록 설정
oooppq 7449000
hotfix: 로그아웃 설정 마무리
oooppq 5d68522
hotfix: 회원가입 화면 window가 아주 커졌을 때 패딩이 너무 넓어지는 문제 수정
oooppq 1b47903
hotfix: 회원가입 에러가 제대로 처리되지 않는 문제 수정
oooppq 3324914
hotfix: token exp 타임이 지나서 cookie를 삭제할 때의 error 해결
oooppq aeb66c8
hotfix: 아이디 검증 정규표현식 수정
oooppq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": ["next/core-web-vitals", "prettier"], | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## PR 요약 | ||
|
||
> summary | ||
|
||
## 변경된 점 | ||
|
||
> changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: git push into another repo to deploy to vercel | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: pandoc/latex | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install mustache (to update the date) | ||
run: apk add ruby && gem install mustache | ||
- name: creates output | ||
run: sh ./build.sh | ||
- name: Pushes to another repository | ||
id: push_directory | ||
uses: cpina/github-action-push-to-another-repository@main | ||
env: | ||
API_TOKEN_GITHUB: ${{ secrets.DAEGYUN_GITHUB_SECRET }} | ||
with: | ||
source-directory: 'output' | ||
destination-github-username: oooppq | ||
destination-repository-name: react-vote-18th | ||
user-email: ${{ secrets.DAEGYUN_GITHUB_EMAIL }} | ||
commit-message: ${{ github.event.commits[0].message }} | ||
target-branch: main | ||
- name: Test get variable exported by push-to-another-repository | ||
run: echo $DESTINATION_CLONED_DIRECTORY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { TUserInfo } from '@/types'; | ||
import { cookies } from 'next/headers'; | ||
|
||
const EXP_LIMIT = 1000 * 60 * 60 * 24; | ||
|
||
export async function POST(request: Request) { | ||
const body = await request.json(); | ||
const res = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/users/login`, { | ||
headers: { 'Content-Type': 'application/json' }, | ||
method: 'POST', | ||
body: JSON.stringify({ loginId: body.loginId, password: body.password }), | ||
cache: 'no-cache', | ||
}); | ||
|
||
if (res.ok) { | ||
const authInfo = await res.json(); | ||
cookies().set( | ||
'user_info', | ||
JSON.stringify({ | ||
...authInfo, | ||
expTime: new Date().getTime() + EXP_LIMIT, | ||
}), | ||
{ | ||
httpOnly: true, | ||
secure: process.env.NODE_ENV === 'production', | ||
sameSite: 'strict', | ||
maxAge: EXP_LIMIT, | ||
path: '/', | ||
} | ||
); | ||
|
||
return new Response('Authorized', { | ||
status: 200, | ||
}); | ||
} else if (res.status === 404) { | ||
return new Response('Wrong ID', { | ||
status: 404, | ||
}); | ||
} else if (res.status === 401) { | ||
return new Response('Wrong Password', { | ||
status: 401, | ||
}); | ||
} else { | ||
Comment on lines
+32
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return new Response('Login Failed', { | ||
status: 403, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { cookies } from 'next/headers'; | ||
|
||
export async function POST(request: Request) { | ||
const clientReqHeaders = request.headers; | ||
|
||
const serverReqHeaders = new Headers(); | ||
serverReqHeaders.set('AUTHORIZATION', clientReqHeaders.get('AUTHORIZATION')!); | ||
const res = await fetch( | ||
`${process.env.NEXT_PUBLIC_SERVER_URL}/users/logout`, | ||
{ | ||
method: 'POST', | ||
headers: serverReqHeaders, | ||
cache: 'no-cache', | ||
} | ||
); | ||
cookies().delete('user_info'); | ||
if (res.ok) { | ||
return new Response('Logout Success', { | ||
status: 200, | ||
}); | ||
} else | ||
return new Response('Logout Failed', { | ||
status: 400, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { TUserInfo } from '@/types'; | ||
import { cookies } from 'next/headers'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function GET() { | ||
const cookieStore = cookies(); | ||
const stored = cookieStore.get('user_info'); | ||
if (!stored) { | ||
return NextResponse.json(null); | ||
} | ||
const userInfo: TUserInfo = JSON.parse(stored.value); | ||
if (userInfo.expTime < new Date().getTime()) { | ||
cookieStore.delete('user_info'); | ||
return NextResponse.json(null); | ||
} | ||
return NextResponse.json(userInfo); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { getSession } from '@/utils/auth'; | ||
import { cookies } from 'next/headers'; | ||
|
||
export async function POST(req: Request) { | ||
const userInfo = await getSession(); | ||
|
||
try { | ||
const body = await req.json(); | ||
|
||
const token = req.headers.get('AUTHORIZATION'); | ||
if (!token) { | ||
throw new Error('Invalid token'); | ||
} | ||
const res = await fetch( | ||
`${process.env.NEXT_PUBLIC_SERVER_URL}/demoday/votes`, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
AUTHORIZATION: token, | ||
}, | ||
method: 'POST', | ||
body: JSON.stringify({ teamName: body.teamName }), | ||
cache: 'no-cache', | ||
} | ||
); | ||
|
||
if (res.ok) { | ||
cookies().set( | ||
'user_info', | ||
JSON.stringify({ | ||
...userInfo, | ||
teamVoted: true, | ||
}) | ||
); | ||
return new Response( | ||
JSON.stringify({ message: 'Vote registered successfully' }), | ||
{ | ||
status: 201, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
} | ||
); | ||
} else if (res.status === 403) { | ||
return new Response( | ||
JSON.stringify({ message: 'Token expired or invalid' }), | ||
{ | ||
status: 403, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
} | ||
); | ||
} else { | ||
const errorResponse = await res.json(); | ||
return new Response(JSON.stringify(errorResponse), { | ||
status: res.status, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} catch (error) { | ||
return new Response(JSON.stringify({ message: 'An error occurred' }), { | ||
status: 500, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { getSession } from '@/utils/auth'; | ||
import { cookies } from 'next/headers'; | ||
|
||
export async function POST(req: Request) { | ||
const userInfo = await getSession(); | ||
const part = userInfo?.part; | ||
try { | ||
const body = await req.json(); | ||
const token = req.headers.get('AUTHORIZATION'); | ||
if (!token) { | ||
throw new Error('Invalid token'); | ||
} | ||
|
||
const res = await fetch( | ||
`${process.env.NEXT_PUBLIC_SERVER_URL}/part-leader/votes?part=${part}`, | ||
{ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
AUTHORIZATION: token, | ||
}, | ||
method: 'POST', | ||
body: JSON.stringify({ id: body.id }), | ||
cache: 'no-cache', | ||
} | ||
); | ||
|
||
if (res.ok) { | ||
cookies().set( | ||
'user_info', | ||
JSON.stringify({ | ||
...userInfo, | ||
candidateVoted: true, | ||
}) | ||
); | ||
return new Response( | ||
JSON.stringify({ message: 'Vote registered successfully' }), | ||
{ | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
} | ||
); | ||
} else if (res.status === 403) { | ||
return new Response(JSON.stringify({ message: 'Token expired' }), { | ||
status: 403, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} else { | ||
const errorResponse = await res.json(); | ||
return new Response(JSON.stringify(errorResponse), { | ||
status: res.status, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} catch (error) { | ||
return new Response(JSON.stringify({ message: 'An error occurred' }), { | ||
status: 409, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저희는 localStorage에 토큰 저장해서 처리했는데 이렇게 쿠키 쓸 수도 있군요! 보안 상 더 안정적일 것 같네요 ~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿠키로 관리하는 법 배워갑니다!