Skip to content

Commit 3ba4af6

Browse files
committed
Resolves velopert#205
1 parent e3c597f commit 3ba4af6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/containers/auth/AuthModalContainer.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { RootState } from '../../modules';
1111
import { sendAuthEmail, SendAuthEmailResponse } from '../../lib/api/auth';
1212
import useRequest from '../../lib/hooks/useRequest';
1313
import { useLocation } from 'react-router-dom';
14+
import { toast } from 'react-toastify';
1415

1516
interface OwnProps {}
1617
interface StateProps {
@@ -49,6 +50,10 @@ const AuthModalContainer: React.FC<AuthModalContainerProps> = ({
4950

5051
const onSendAuthEmail = useCallback(
5152
async (email: string) => {
53+
if (!validateEmail(email)) {
54+
toast.error('잘못된 이메일 형식입니다.');
55+
return;
56+
}
5257
_sendAuthEmail(email);
5358
},
5459
[_sendAuthEmail],
@@ -68,8 +73,13 @@ const AuthModalContainer: React.FC<AuthModalContainerProps> = ({
6873
);
6974
};
7075

76+
function validateEmail(email: string) {
77+
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
78+
return re.test(String(email).toLowerCase());
79+
}
80+
7181
export default connect<StateProps, DispatchProps, OwnProps, RootState>(
72-
state => ({
82+
(state) => ({
7383
visible: state.core.auth.visible,
7484
mode: state.core.auth.mode,
7585
}),

0 commit comments

Comments
 (0)