-
Notifications
You must be signed in to change notification settings - Fork 3
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
[#51] 이메일 인증 페이지 생성 #44
Open
gyuZzang
wants to merge
6
commits into
develop
Choose a base branch
from
feature/#51
base: develop
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 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cb82e06
feat(user/auth): 이메일 인증 페이지 생성 [#51]
gyuZzang 31ef682
Merge branch 'develop' into feature/#51
gunhoflash 2f61fed
test for click up
gyuZzang b6d5bd5
Merge branch 'develop' of https://github.com/UOSTime/UOSTime-Client i…
gyuZzang 53c03d3
feat: 이메일 인증 API 로직 추가
gyuZzang e4177eb
feat(emailAuth): 이메일 인증 코드 api 수정 적용(userID), css 추가
gyuZzang 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
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
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,85 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { requestAPI, API_SEND_CODE, API_AUTH_EMAIL, API_MY_INFO } from '@utils/api'; | ||
import { Button, Box, makeStyles, Container, Typography } from '@material-ui/core'; | ||
import UosInput from '@components/UosInput'; | ||
|
||
|
||
export default function EmailAuth() { | ||
const userID = window.localStorage.getItem('userID'); | ||
const [userEmail,setUserEmail] = useState(null); | ||
const [isCodeSend, setIsCodeSend] = useState(false); | ||
const [code, setCode] = useState(null); | ||
|
||
useEffect(async()=> { | ||
try{ | ||
const res = await requestAPI(API_MY_INFO, userID); | ||
gyuZzang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
setUserEmail(res.data.email); | ||
} | ||
catch(err){ | ||
alert(err); | ||
throw err; | ||
} | ||
},[]) | ||
|
||
const inputOnChange = (e) => { | ||
setCode(e.target.value); | ||
}; | ||
|
||
const onEnterPress = (e) => { | ||
if(e.key == 'Enter') { | ||
handleAuth(); | ||
} | ||
}; | ||
|
||
const handleSendCode = async () => { | ||
console.log(userEmail); | ||
try{ | ||
await requestAPI(API_SEND_CODE(), {email: userEmail}); | ||
} | ||
catch(err){ | ||
alert(err.message); | ||
throw err; | ||
} | ||
} | ||
|
||
const handleAuth = async () => { | ||
console.log(userID, code); | ||
try{ | ||
const res = await requestAPI(API_AUTH_EMAIL(userID, code)); | ||
gyuZzang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if(res.status === 204){ | ||
gyuZzang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
alert('이메일이 성공적으로 인증되었습니다!'); | ||
} | ||
} | ||
catch(err){ | ||
alert(err) | ||
throw err; | ||
} | ||
} | ||
|
||
return( //TODO: 컴포넌트로 나누기 | ||
<Container> | ||
<Container> | ||
<Typography>이메일 인증</Typography> | ||
<Container> | ||
<Typography>{userEmail}</Typography> | ||
<Button onClick={handleSendCode}> | ||
인증 코드 전송 | ||
</Button> | ||
</Container> | ||
</Container> | ||
|
||
{isCodeSend && | ||
<Container> | ||
<UosInput | ||
type='password' | ||
name='code' | ||
label='인증코드' | ||
onChange={inputOnChange} | ||
onKeyPress={onEnterPress} | ||
value={code} | ||
/> | ||
<Button onClick={handleAuth}>인증</Button> | ||
</Container>} | ||
</Container> | ||
) | ||
} |
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.
함수로 만든 건 의도하신 건가요??
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.
@Dormarble post (/user/auth) 에서 path params이 있는거랑 없는거랑 작동하는 방식이 다른데, api.js에는 하나로만 세팅하고, 프론트에서 API호출 시 setPathParams 세팅 여부에 따라 백에서 분기되는 건가요?