File tree Expand file tree Collapse file tree
infrastructure/eid-wallet/src/routes/(app)/settings/pin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,12 +32,34 @@ const stepTitle = $derived(
3232 : " Confirm your new PIN" ,
3333);
3434
35- function advance() {
36- if (! canSubmit ) return ;
35+ async function advance() {
36+ if (! canSubmit || submitting ) return ;
3737 error = null ;
3838 if (step === " current" ) {
39- step = " new" ;
39+ if (! globalState ) return ;
40+ submitting = true ;
41+ try {
42+ const ok =
43+ await globalState .securityController .verifyPin (currentPin );
44+ if (! ok ) {
45+ error = " That's not your current PIN. Try again." ;
46+ currentPin = " " ;
47+ return ;
48+ }
49+ step = " new" ;
50+ } catch (err ) {
51+ console .error (" Failed to verify current PIN:" , err );
52+ error = " Couldn't verify your current PIN. Try again." ;
53+ currentPin = " " ;
54+ } finally {
55+ submitting = false ;
56+ }
4057 } else if (step === " new" ) {
58+ if (newPin === currentPin ) {
59+ error = " Your new PIN must be different from your current PIN." ;
60+ newPin = " " ;
61+ return ;
62+ }
4163 step = " repeat" ;
4264 } else {
4365 void submit ();
@@ -148,7 +170,7 @@ onMount(() => {
148170 class =" w-full uppercase tracking-wide"
149171 disabled ={! canSubmit || submitting }
150172 callback ={advance }
151- blockingClick ={step === " repeat " }
173+ blockingClick ={step !== " new " }
152174 >
153175 {step === " repeat" ? " Change PIN" : " Next" }
154176 </ButtonAction >
You can’t perform that action at this time.
0 commit comments