@@ -43,6 +43,29 @@ class AuthAction {
4343 this . _nav . goPassword ( ) ;
4444 }
4545
46+ /**
47+ * Initialize the reset pin flow by resetting input values
48+ * and then navigating to the view.
49+ * @return {undefined }
50+ */
51+ initResetPin ( ) {
52+ this . _store . auth . resetPinCurrent = '' ;
53+ this . _store . auth . resetPinNew = '' ;
54+ this . _store . auth . resetPinVerify = '' ;
55+ this . _nav . goResetPasswordCurrent ( ) ;
56+ }
57+
58+ /**
59+ * Initialize the reset new pin flow by resetting new values
60+ * and then navigating to the new pin view.
61+ * @return {undefined }
62+ */
63+ initResetPinNew ( ) {
64+ this . _store . auth . resetPinNew = '' ;
65+ this . _store . auth . resetPinVerify = '' ;
66+ this . _nav . goResetPasswordNew ( ) ;
67+ }
68+
4669 /**
4770 * Append a digit input to the pin parameter.
4871 * @param {string } options.digit The digit to append to the pin
@@ -63,6 +86,12 @@ class AuthAction {
6386 this . checkNewPin ( ) ;
6487 } else if ( param === 'pin' ) {
6588 this . checkPin ( ) ;
89+ } else if ( param === 'resetPinCurrent' ) {
90+ this . _nav . goResetPasswordNew ( ) ;
91+ } else if ( param === 'resetPinNew' ) {
92+ this . _nav . goResetPasswordConfirm ( ) ;
93+ } else if ( param === 'resetPinVerify' ) {
94+ this . checkResetPin ( ) ;
6695 }
6796 }
6897
@@ -77,6 +106,12 @@ class AuthAction {
77106 auth [ param ] = auth [ param ] . slice ( 0 , - 1 ) ;
78107 } else if ( param === 'pinVerify' ) {
79108 this . initSetPin ( ) ;
109+ } else if ( param === 'resetPinCurrent' ) {
110+ this . _nav . goSettings ( ) ;
111+ } else if ( param === 'resetPinNew' ) {
112+ this . initResetPin ( ) ;
113+ } else if ( param === 'resetPinVerify' ) {
114+ this . initResetPinNew ( ) ;
80115 }
81116 }
82117
@@ -113,6 +148,33 @@ class AuthAction {
113148 await this . _unlockWallet ( ) ;
114149 }
115150
151+ /**
152+ * Check that the pin that was chosen by the user doesn't match
153+ * their current pin, and that it was entered correctly twice.
154+ * If everything is ok, store the pin in the keystore and redirect
155+ * to home.
156+ * @return {undefined }
157+ */
158+ async checkResetPin ( ) {
159+ const { resetPinCurrent, resetPinNew, resetPinVerify } = this . _store . auth ;
160+ const storedPin = await this . _getFromKeyStore ( PIN ) ;
161+ if ( resetPinCurrent !== storedPin ) {
162+ this . _alert ( 'Incorrect PIN' , ( ) => this . initResetPin ( ) ) ;
163+ return ;
164+ } else if ( resetPinCurrent === resetPinNew ) {
165+ this . _alert ( 'New PIN must not match old PIN' , ( ) => this . initResetPin ( ) ) ;
166+ return ;
167+ } else if (
168+ resetPinNew . length !== PIN_LENGTH ||
169+ resetPinNew !== resetPinVerify
170+ ) {
171+ this . _alert ( "PINs don't match" , ( ) => this . initResetPin ( ) ) ;
172+ return ;
173+ }
174+ await this . _setToKeyStore ( PIN , resetPinNew ) ;
175+ this . _nav . goResetPasswordSaved ( ) ;
176+ }
177+
116178 //
117179 // TouchID & KeyStore Authentication
118180 //
0 commit comments