@@ -352,42 +352,60 @@ def verify_credentials(self):
352352 Sends a final hash of (salt+password)+key and token to Nord api
353353 Verifies responses and updates GUI
354354 """
355- try :
356- resp = requests .get ('https://api.nordvpn.com/token/token/' + self .user_input .text (), timeout = 5 )
357- if resp .status_code == requests .codes .ok :
358- token_json = json .loads (resp .text )
359- token = token_json ['token' ]
360- salt = token_json ['salt' ]
361- key = token_json ['key' ]
362-
363- password_hash = hashlib .sha512 (salt .encode () + self .password_input .text ().encode ())
364- final_hash = hashlib .sha512 (password_hash .hexdigest ().encode () + key .encode ())
355+ if self .user_input .text () and self .password_input .text ():
356+ self .statusbar .showMessage ('Login Success' , 2000 )
357+ self .username = self .user_input .text ()
358+ self .password = self .password_input .text ()
359+ self .repaint ()
360+ time .sleep (0.5 )
361+ self .hide ()
362+ self .main_ui ()
363+ else :
364+ self .statusbar .showMessage ('Username or password field cannot be empty, 2000' )
365+ # try:
366+ # resp = requests.get('https://apself.statusbar.showMessage('Login Success', 2000)
367+ # self.username = self.user_input.text()
368+ # self.password = self.password_input.text()
369+ # self.repaint()
370+ # time.sleep(0.5)
371+ # self.hide()
372+ # self.main_ui()i.nordvpn.com/token/token/' + self.user_input.text(), timeout=5)
373+ #
374+ # if resp.status_code == requests.codes.ok:
375+ # token_json = json.loads(resp.text)
376+ # token = token_json['token']
377+ # salt = token_json['salt']
378+ # key = token_json['key']
379+ #
380+ # password_hash = hashlib.sha512(salt.encode() + self.password_input.text().encode())
381+ # final_hash = hashlib.sha512(password_hash.hexdigest().encode() + key.encode())
382+ #
383+ # try:
384+ # resp = requests.get('https://api.nordvpn.com/token/verify/' + token + '/' + final_hash.hexdigest(), timeout=5)
385+ # if resp.status_code == requests.codes.ok:
386+ # self.statusbar.showMessage('Login Success', 2000)
387+ # self.username = self.user_input.text()
388+ # self.password = self.password_input.text()
389+ # self.repaint()
390+ # time.sleep(0.5)
391+ # self.hide()
392+ # self.main_ui()
393+ # else:
394+ # self.statusbar.showMessage('Invalid Credentials', 2000)
395+ # self.user_input.clear()
396+ # self.password_input.clear()
397+ # self.user_input.setFocus()
398+ # except Exception as ex:
399+ # self.statusbar.showMessage('Invalid Credentials', 2000)
400+ # self.user_input.clear()
401+ # self.password_input.clear()
402+ # self.user_input.setFocus()
403+ # else:
404+ # self.statusbar.showMessage("API Error: could not fetch token", 2000)
405+ # except Exception as ex:
406+ # self.statusbar.showMessage("API Error: could not fetch token", 2000)
407+ # self.get_api_data()
365408
366- try :
367- resp = requests .get ('https://api.nordvpn.com/token/verify/' + token + '/' + final_hash .hexdigest (), timeout = 5 )
368- if resp .status_code == requests .codes .ok :
369- self .statusbar .showMessage ('Login Success' , 2000 )
370- self .username = self .user_input .text ()
371- self .password = self .password_input .text ()
372- self .repaint ()
373- time .sleep (0.5 )
374- self .hide ()
375- self .main_ui ()
376- else :
377- self .statusbar .showMessage ('Invalid Credentials' , 2000 )
378- self .user_input .clear ()
379- self .password_input .clear ()
380- self .user_input .setFocus ()
381- except Exception as ex :
382- self .statusbar .showMessage ('Invalid Credentials' , 2000 )
383- self .user_input .clear ()
384- self .password_input .clear ()
385- self .user_input .setFocus ()
386- else :
387- self .statusbar .showMessage ("API Error: could not fetch token" , 2000 )
388- except Exception as ex :
389- self .statusbar .showMessage ("API Error: could not fetch token" , 2000 )
390- self .get_api_data ()
391409 def get_api_data (self ):
392410 """
393411 Gets json file containing server information
@@ -544,6 +562,8 @@ def add_secrets(self):
544562 try :
545563 self .statusbar .showMessage ("Adding Secrets..." , 1000 )
546564 self .repaint ()
565+ password_flag = subprocess .run (['nmcli' , 'connection' , 'modify' , self .connection_name , '+vpn.data' , 'password-flags=0' ])
566+ password_flag .check_returncode ()
547567 secrets = subprocess .run (['nmcli' , 'connection' , 'modify' , self .connection_name , '+vpn.secrets' , 'password=' + self .password ])
548568 secrets .check_returncode ()
549569 user_secret = subprocess .run (['nmcli' , 'connection' , 'modify' , self .connection_name , '+vpn.data' , 'username=' + self .username ])
0 commit comments