@@ -7,7 +7,7 @@ use async_std::{
77 channel:: { Receiver , Sender } ,
88 sync:: Mutex as AsyncMutex ,
99} ;
10- use credentialsd_common:: model:: RequestingApplication ;
10+ use credentialsd_common:: model:: { RequestingApplication , ViewUpdateSuccess } ;
1111use credentialsd_common:: server:: ViewRequest ;
1212use gettextrs:: gettext;
1313use serde:: { Deserialize , Serialize } ;
@@ -89,6 +89,7 @@ impl<F: FlowController + Send> ViewModel<F> {
8989 // TRANSLATORS: %s1 is the "relying party" (think: domain name) where the request is coming from
9090 gettext ( "Use a passkey for %s1" )
9191 }
92+ Operation :: SetDevicePin => gettext ( "Setting Pin on device" ) ,
9293 }
9394 . to_string ( ) ;
9495 title = title. replace ( "%s1" , & self . rp_id ) ;
@@ -108,6 +109,7 @@ impl<F: FlowController + Send> ViewModel<F> {
108109 // TRANSLATORS: %s3 is the absolute path (think: /usr/bin/firefox) of the requesting application
109110 gettext ( "<b>\" %s2\" </b> (process ID: %i1, binary: %s3) is asking to use a credential to sign in to \" %s1\" . Only proceed if you trust this process." )
110111 }
112+ Operation :: SetDevicePin => gettext ( "Setting Pin on device" ) ,
111113 }
112114 . to_string ( ) ;
113115 subtitle = subtitle. replace ( "%s1" , & self . rp_id ) ;
@@ -216,6 +218,7 @@ impl<F: FlowController + Send> ViewModel<F> {
216218 Event :: View ( ViewEvent :: SetNewDevicePin ( pin) ) => {
217219 if let Some ( device) = & self . selected_device {
218220 let mut cred_service = self . flow_controller . lock ( ) . await ;
221+ self . operation = Operation :: SetDevicePin ;
219222 let resp = match device. transport {
220223 Transport :: Usb => cred_service. set_usb_device_pin ( pin) . await ,
221224 Transport :: Nfc => cred_service. set_nfc_device_pin ( pin) . await ,
@@ -282,7 +285,15 @@ impl<F: FlowController + Send> ViewModel<F> {
282285 . unwrap ( ) ;
283286 }
284287 UsbState :: Completed => {
285- self . tx_update . send ( ViewUpdate :: Completed ) . await . unwrap ( ) ;
288+ let t = if matches ! ( self . operation, Operation :: SetDevicePin ) {
289+ ViewUpdateSuccess :: KeepWindowOpen ( gettext (
290+ "Pin successfully set! Please try registering again." ,
291+ ) )
292+ } else {
293+ ViewUpdateSuccess :: CloseWindow
294+ } ;
295+
296+ self . tx_update . send ( ViewUpdate :: Completed ( t) ) . await . unwrap ( ) ;
286297 }
287298 UsbState :: SelectingDevice => {
288299 self . tx_update
@@ -353,7 +364,14 @@ impl<F: FlowController + Send> ViewModel<F> {
353364 . unwrap ( ) ;
354365 }
355366 NfcState :: Completed => {
356- self . tx_update . send ( ViewUpdate :: Completed ) . await . unwrap ( ) ;
367+ let t = if matches ! ( self . operation, Operation :: SetDevicePin ) {
368+ ViewUpdateSuccess :: KeepWindowOpen ( gettext (
369+ "Pin successfully set! Please try registering again." ,
370+ ) )
371+ } else {
372+ ViewUpdateSuccess :: CloseWindow
373+ } ;
374+ self . tx_update . send ( ViewUpdate :: Completed ( t) ) . await . unwrap ( ) ;
357375 }
358376 NfcState :: Idle | NfcState :: Waiting => { }
359377 NfcState :: SelectingCredential { creds } => {
@@ -429,7 +447,10 @@ impl<F: FlowController + Send> ViewModel<F> {
429447 }
430448 HybridState :: Completed => {
431449 self . hybrid_qr_code_data = None ;
432- self . tx_update . send ( ViewUpdate :: Completed ) . await . unwrap ( ) ;
450+ self . tx_update
451+ . send ( ViewUpdate :: Completed ( ViewUpdateSuccess :: CloseWindow ) )
452+ . await
453+ . unwrap ( ) ;
433454 }
434455 HybridState :: UserCancelled => {
435456 self . hybrid_qr_code_data = None ;
0 commit comments