Skip to content

Commit

Permalink
Add password reset command
Browse files Browse the repository at this point in the history
  • Loading branch information
jpattWPC committed Oct 13, 2023
1 parent 3762af5 commit 2bac614
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/vdiclient.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"upgrade_guid" : "46cbad92-353e-4b28-9bee-83950991dad8",
"version" : "1.2.04",
"version" : "1.2.05",
"product_name" : "VDI Client",
"manufacturer" : "Josh Patten",
"name" : "VDI Client",
Expand Down
2 changes: 2 additions & 0 deletions vdiclient.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ tls_verify = false
#token_name = dvi
# API Token Value
#token_value = xxx-x-x-x-xxx
# Password Reset Command Launch. Has to be full executable Command
#pwresetcmd = start chrome --app=http://pwreset.example.com

[Hosts]
# Hosts are entered as `IP/FQDN = Port`
Expand Down
17 changes: 13 additions & 4 deletions vdiclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class G:
guest_type = 'both'
width = None
height = None
pwresetcmd = None

def loadconfig(config_location = None):
if config_location:
Expand Down Expand Up @@ -117,11 +118,13 @@ def loadconfig(config_location = None):
if 'tls_verify' in config['Authentication']:
G.verify_ssl = config['Authentication'].getboolean('tls_verify')
if 'user' in config['Authentication']:
G.user = config['Authentication']['user']
G.user = config['Authentication']['user']
if 'token_name' in config['Authentication']:
G.token_name = config['Authentication']['token_name']
G.token_name = config['Authentication']['token_name']
if 'token_value' in config['Authentication']:
G.token_value = config['Authentication']['token_value']
G.token_value = config['Authentication']['token_value']
if 'pwresetcmd' in config['Authentication']:
G.pwresetcmd = config['Authentication']['pwresetcmd']
if not 'Hosts' in config:
win_popup_button(f'Unable to read supplied configuration:\nNo `Hosts` section defined!', 'OK')
return False
Expand Down Expand Up @@ -180,6 +183,8 @@ def setmainlayout():
layout.append([sg.Button("Log In", font=["Helvetica", 14], bind_return_key=True)])
else:
layout.append([sg.Button("Log In", font=["Helvetica", 14], bind_return_key=True), sg.Button("Cancel", font=["Helvetica", 14])])
if G.pwresetcmd:
layout[-1].append(sg.Button('Password Reset', font=["Helvetica", 14]))
return layout

def getvms(listonly = False):
Expand Down Expand Up @@ -483,6 +488,11 @@ def loginwindow():
if event == 'Cancel' or event == sg.WIN_CLOSED:
window.close()
return False
elif event == 'Password Reset':
try:
subprocess.check_call(G.pwresetcmd, shell=True)
except Exception as e:
win_popup_button(f'Unable to open password reset command.\n\nError Info:\n{e}', 'OK')
else:
if event in ('Log In', '\r', 'special 16777220', 'special 16777221'):
popwin = win_popup("Please wait, authenticating...")
Expand Down Expand Up @@ -513,7 +523,6 @@ def showvms():
win_popup_button('No desktop instances found, please consult with your system administrator', 'OK')
return False
layout = setvmlayout(vms)

if G.icon:
window = sg.Window(G.title, layout, return_keyboard_events=True, finalize=True, resizable=False, no_titlebar=G.kiosk, size=(G.width, G.height), icon=G.icon)
else:
Expand Down

0 comments on commit 2bac614

Please sign in to comment.