mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-22 02:17:26 +00:00
Merge pull request #372 from hnk/fix-spaces_in_password
fix(read_password): regex check for spaces, quotes
This commit is contained in:
commit
d3239b49ce
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import sys, getpass, urllib.request, urllib.error, json
|
import sys, getpass, urllib.request, urllib.error, json, re
|
||||||
|
|
||||||
def mgmt(cmd, data=None, is_json=False):
|
def mgmt(cmd, data=None, is_json=False):
|
||||||
# The base URL for the management daemon. (Listens on IPv4 only.)
|
# The base URL for the management daemon. (Listens on IPv4 only.)
|
||||||
@ -31,11 +31,14 @@ def read_password():
|
|||||||
while True:
|
while True:
|
||||||
first = getpass.getpass('password: ')
|
first = getpass.getpass('password: ')
|
||||||
if len(first) < 4:
|
if len(first) < 4:
|
||||||
print('Passwords must be at least four characters.')
|
print("Passwords must be at least four characters.")
|
||||||
|
continue
|
||||||
|
if re.search(r'[\s]', first):
|
||||||
|
print("Passwords cannot contain spaces.")
|
||||||
continue
|
continue
|
||||||
second = getpass.getpass(' (again): ')
|
second = getpass.getpass(' (again): ')
|
||||||
if first != second:
|
if first != second:
|
||||||
print('Passwords not the same. Try again.')
|
print("Passwords not the same. Try again.")
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
return first
|
return first
|
||||||
|
Loading…
Reference in New Issue
Block a user