@@ -440,30 +440,31 @@ def verify_credentials(self):
440440 else :
441441 self .statusbar .showMessage ('Username or password field cannot be empty' , 2000 )
442442 try :
443- # check whether credentials should be saved
444- if self .remember_checkBox .isChecked ():
445- try :
446- keyring .set_password ("NordVPN" , self .username , self .password )
447- self .config ['USER' ]['USER_NAME' ] = self .username
448- self .write_conf ()
449- except Exception as ex :
450- self .statusbar .showMessage ("Error accessing keyring" , 1000 )
451- time .sleep (1 )
452-
453- # Delete credentials if found
454- else :
455- try :
456- keyring .delete_password ("NordVPN" , self .username )
457- self .config ['USER' ]['USER_NAME' ] = 'None'
458- self .write_conf ()
459- except Exception as ex :
460- self .statusbar .showMessage ("No saved credentials to delete" , 1000 )
461- time .sleep (0.5 )
462443
463444 # post username and password to api endpoint
464445 json_data = {'username' : self .username , 'password' : self .password }
465446 resp = requests .post ('https://api.nordvpn.com/v1/users/tokens' , json = json_data , timeout = 5 )
466447 if resp .status_code == 201 :
448+ # check whether credentials should be saved
449+ if self .remember_checkBox .isChecked ():
450+ try :
451+ keyring .set_password ("NordVPN" , self .username , self .password )
452+ self .config ['USER' ]['USER_NAME' ] = self .username
453+ self .write_conf ()
454+ except Exception as ex :
455+ self .statusbar .showMessage ("Error accessing keyring" , 1000 )
456+ time .sleep (1 )
457+
458+ # Delete credentials if found
459+ else :
460+ try :
461+ keyring .delete_password ("NordVPN" , self .username )
462+ self .config ['USER' ]['USER_NAME' ] = 'None'
463+ self .write_conf ()
464+ except Exception as ex :
465+ self .statusbar .showMessage ("No saved credentials to delete" , 1000 )
466+ time .sleep (0.5 )
467+
467468 self .statusbar .showMessage ('Login Success' , 2000 )
468469 self .repaint ()
469470 time .sleep (0.5 )
0 commit comments