Skip to content

Commit a772ba3

Browse files
committed
Implement Redirect to opt-in change password page
FIX TODO: Unexpect state flow in handleSubmit when initial submit. However I retry submit, the result state was change to 'changePassword' enum member.
1 parent 31b4f2c commit a772ba3

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/app/app.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,21 @@ export default function App({ optOutUrl }: OptOutUrl) {
3838
const handleSubmit = async (e: SubmitEvent) => {
3939
e.preventDefault()
4040
dispatch(submitCreator(e.target))
41+
if (result === Result.invalid || result === Result.blocked) return
42+
43+
if (isKeepLogin) saveAccountInfo(getElementValues(e.target))
44+
4145
if (result === Result.correct) {
42-
if (isKeepLogin) {
43-
saveAccountInfo(getElementValues(e.target))
44-
}
4546
location.href = 'main.do'
47+
return
4648
}
49+
50+
if (result === Result.changePassword) {
51+
location.href = 'sysUserPwd.do?changepw=y'
52+
return
53+
}
54+
55+
throw Error('Unexpect state flow in handleSubmit')
4756
}
4857

4958
useEffect(() => {

src/app/features/login.common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export enum Result {
3030
'correct',
3131
'invalid',
3232
'blocked',
33+
'changePassword',
3334
}
3435

3536
export interface TargetElements extends EventTarget {

src/app/features/login.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const formSubmit: FormSubmit = async (input: FormData) => {
2222
const invaildMessage = dbError[0].slice(15, -1) as ErrorMessage
2323
return invaildMessage === Exceed ? Result.blocked : Result.invalid
2424
}
25+
if (data.includes('하영Dreamy 비밀번호 변경')) return Result.changePassword
2526
return Result.correct
2627
}
2728

0 commit comments

Comments
 (0)