@@ -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 } ;
@@ -83,6 +83,7 @@ impl<F: FlowController + Send> ViewModel<F> {
8383 // TRANSLATORS: %s1 is the "relying party" (think: domain name) where the request is coming from
8484 gettext ( "Use a passkey for %s1" )
8585 }
86+ Operation :: SetDevicePin => gettext ( "Setting Pin on device" ) ,
8687 }
8788 . to_string ( ) ;
8889 title = title. replace ( "%s1" , & self . rp_id ) ;
@@ -102,6 +103,7 @@ impl<F: FlowController + Send> ViewModel<F> {
102103 // TRANSLATORS: %s3 is the absolute path (think: /usr/bin/firefox) of the requesting application
103104 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." )
104105 }
106+ Operation :: SetDevicePin => gettext ( "Setting Pin on device" ) ,
105107 }
106108 . to_string ( ) ;
107109 subtitle = subtitle. replace ( "%s1" , & self . rp_id ) ;
@@ -210,6 +212,7 @@ impl<F: FlowController + Send> ViewModel<F> {
210212 Event :: View ( ViewEvent :: SetNewDevicePin ( pin) ) => {
211213 if let Some ( device) = & self . selected_device {
212214 let mut cred_service = self . flow_controller . lock ( ) . await ;
215+ self . operation = Operation :: SetDevicePin ;
213216 let resp = match device. transport {
214217 Transport :: Usb => cred_service. set_usb_device_pin ( pin) . await ,
215218 Transport :: Nfc => cred_service. set_nfc_device_pin ( pin) . await ,
@@ -276,7 +279,15 @@ impl<F: FlowController + Send> ViewModel<F> {
276279 . unwrap ( ) ;
277280 }
278281 UsbState :: Completed => {
279- self . tx_update . send ( ViewUpdate :: Completed ) . await . unwrap ( ) ;
282+ let t = if matches ! ( self . operation, Operation :: SetDevicePin ) {
283+ ViewUpdateSuccess :: KeepWindowOpen ( gettext (
284+ "Pin successfully set! Please try registering again." ,
285+ ) )
286+ } else {
287+ ViewUpdateSuccess :: CloseWindow
288+ } ;
289+
290+ self . tx_update . send ( ViewUpdate :: Completed ( t) ) . await . unwrap ( ) ;
280291 }
281292 UsbState :: SelectingDevice => {
282293 self . tx_update
@@ -347,7 +358,14 @@ impl<F: FlowController + Send> ViewModel<F> {
347358 . unwrap ( ) ;
348359 }
349360 NfcState :: Completed => {
350- self . tx_update . send ( ViewUpdate :: Completed ) . await . unwrap ( ) ;
361+ let t = if matches ! ( self . operation, Operation :: SetDevicePin ) {
362+ ViewUpdateSuccess :: KeepWindowOpen ( gettext (
363+ "Pin successfully set! Please try registering again." ,
364+ ) )
365+ } else {
366+ ViewUpdateSuccess :: CloseWindow
367+ } ;
368+ self . tx_update . send ( ViewUpdate :: Completed ( t) ) . await . unwrap ( ) ;
351369 }
352370 NfcState :: Idle | NfcState :: Waiting => { }
353371 NfcState :: SelectCredential { creds } => {
@@ -423,7 +441,10 @@ impl<F: FlowController + Send> ViewModel<F> {
423441 }
424442 HybridState :: Completed => {
425443 self . hybrid_qr_code_data = None ;
426- self . tx_update . send ( ViewUpdate :: Completed ) . await . unwrap ( ) ;
444+ self . tx_update
445+ . send ( ViewUpdate :: Completed ( ViewUpdateSuccess :: CloseWindow ) )
446+ . await
447+ . unwrap ( ) ;
427448 }
428449 HybridState :: UserCancelled => {
429450 self . hybrid_qr_code_data = None ;
0 commit comments