@@ -47,7 +47,8 @@ export default class ForgotPassword extends AuthPiece {
47
47
}
48
48
49
49
send ( ) {
50
- const { username } = this . inputs ;
50
+ const { authData= { } } = this . props ;
51
+ const username = this . inputs . username || authData . username ;
51
52
if ( ! Auth || typeof Auth . forgotPassword !== 'function' ) {
52
53
throw new Error ( 'No Auth module found, please ensure @aws-amplify/auth is imported' ) ;
53
54
}
@@ -60,7 +61,10 @@ export default class ForgotPassword extends AuthPiece {
60
61
}
61
62
62
63
submit ( ) {
63
- const { username, code, password } = this . inputs ;
64
+ const { authData= { } } = this . props ;
65
+ const { code, password } = this . inputs ;
66
+ const username = this . inputs . username || authData . username ;
67
+
64
68
if ( ! Auth || typeof Auth . forgotPasswordSubmit !== 'function' ) {
65
69
throw new Error ( 'No Auth module found, please ensure @aws-amplify/auth is imported' ) ;
66
70
}
@@ -117,24 +121,24 @@ export default class ForgotPassword extends AuthPiece {
117
121
}
118
122
119
123
showComponent ( theme ) {
120
- const { authState, hide } = this . props ;
124
+ const { authState, hide, authData = { } } = this . props ;
121
125
if ( hide && hide . includes ( ForgotPassword ) ) { return null ; }
122
126
123
127
return (
124
128
< FormSection theme = { theme } >
125
129
< SectionHeader theme = { theme } > { I18n . get ( 'Reset your password' ) } </ SectionHeader >
126
130
< SectionBody >
127
- { this . state . delivery ? this . submitView ( ) : this . sendView ( ) }
131
+ { this . state . delivery || authData . username ? this . submitView ( ) : this . sendView ( ) }
128
132
</ SectionBody >
129
133
< SectionFooter theme = { theme } >
130
134
< SectionFooterPrimaryContent theme = { theme } >
131
- { this . state . delivery ?
135
+ { this . state . delivery || authData . username ?
132
136
< Button theme = { theme } onClick = { this . submit } > { I18n . get ( 'Submit' ) } </ Button > :
133
137
< Button theme = { theme } onClick = { this . send } > { I18n . get ( 'Send Code' ) } </ Button >
134
138
}
135
139
</ SectionFooterPrimaryContent >
136
140
< SectionFooterSecondaryContent theme = { theme } >
137
- { this . state . delivery ?
141
+ { this . state . delivery || authData . username ?
138
142
< Link theme = { theme } onClick = { this . send } > { I18n . get ( 'Resend Code' ) } </ Link > :
139
143
< Link theme = { theme } onClick = { ( ) => this . changeState ( 'signIn' ) } > { I18n . get ( 'Back to Sign In' ) } </ Link >
140
144
}
0 commit comments