mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
adminpw function
This commit is contained in:
parent
f31be0bacf
commit
615d0202bd
1 changed files with 8 additions and 5 deletions
|
@ -5,7 +5,7 @@ import sys
|
|||
import yaml
|
||||
import re
|
||||
import getpass
|
||||
from yunohost import validate, colorize, get_required_args
|
||||
from yunohost import YunoHostError, validate, colorize, get_required_args
|
||||
|
||||
|
||||
def tools_ldapinit(args, connections):
|
||||
|
@ -58,10 +58,10 @@ def tools_adminpw(args):
|
|||
dict
|
||||
|
||||
"""
|
||||
if not args['old']:
|
||||
if not 'old' in args:
|
||||
args['old'] = getpass.getpass(colorize('Actual admin password: ', 'cyan'))
|
||||
|
||||
if not args['new']:
|
||||
if not 'new' in args:
|
||||
args['new'] = getpass.getpass(colorize('New admin password: ', 'cyan'))
|
||||
pwd2 = getpass.getpass(colorize('Retype new password: ', 'cyan'))
|
||||
if args['new'] != pwd2:
|
||||
|
@ -71,9 +71,12 @@ def tools_adminpw(args):
|
|||
if len(args['new']) < 4:
|
||||
raise YunoHostError(22, _("Password is too short"))
|
||||
|
||||
os.system('ldappasswd -h localhost -D cn=admin,dc=yunohost,dc=org -w "'+ args['old'] +'" -a "'+ args['old'] +'" -s "' + args['new'] + '"')
|
||||
result = os.system('ldappasswd -h localhost -D cn=admin,dc=yunohost,dc=org -w "'+ args['old'] +'" -a "'+ args['old'] +'" -s "' + args['new'] + '"')
|
||||
|
||||
return { 'Success' : _("Admin password has been changed") }
|
||||
if result == 0:
|
||||
return { 'Success' : _("Admin password has been changed") }
|
||||
else:
|
||||
raise YunoHostError(22, _("Invalid password"))
|
||||
|
||||
|
||||
def tools_maindomain(args):
|
||||
|
|
Loading…
Reference in a new issue