Reversed the order for change password on 3.5 UDS

This commit is contained in:
Adolfo Gómez García 2021-10-18 16:59:59 +02:00
parent 564f0e17de
commit 59bd6c1649
3 changed files with 11 additions and 6 deletions

View File

@ -37,6 +37,7 @@ import typing
class LocalLogger: # pylint: disable=too-few-public-methods class LocalLogger: # pylint: disable=too-few-public-methods
linux = False linux = False
windows = True windows = True
serviceLogger = False
logger: typing.Optional[logging.Logger] logger: typing.Optional[logging.Logger]

View File

@ -366,17 +366,19 @@ class CommonService: # pylint: disable=too-many-instance-attributes
''' '''
hostName = platform.operations.getComputerName() hostName = platform.operations.getComputerName()
if hostName.lower() == name.lower():
logger.info('Computer name is already {}'.format(hostName))
return
# Check for password change request for an user # Check for password change request for an user
if userName and newPassword: if userName and newPassword:
changed = True
logger.info('Setting password for configured user') logger.info('Setting password for configured user')
try: try:
platform.operations.changeUserPassword(userName, oldPassword or '', newPassword) platform.operations.changeUserPassword(userName, oldPassword or '', newPassword)
except Exception as e: except Exception as e:
raise Exception('Could not change password for user {} (maybe invalid current password is configured at broker): {} '.format(userName, str(e))) # Logs error, but continue renaming computer
logger.error('Could not change password for user {}: {}'.format(userName, e))
if hostName.lower() == name.lower():
logger.info('Computer name is already {}'.format(hostName))
return
if platform.operations.renameComputer(name): if platform.operations.renameComputer(name):
self.reboot() self.reboot()

View File

@ -34,7 +34,8 @@ import os
import tempfile import tempfile
import typing import typing
import servicemanager # pylint: disable=import-error import servicemanager
from udsactor import service # pylint: disable=import-error
# Valid logging levels, from UDS Broker (uds.core.utils.log). # Valid logging levels, from UDS Broker (uds.core.utils.log).
from .. import loglevel from .. import loglevel
@ -42,6 +43,7 @@ from .. import loglevel
class LocalLogger: # pylint: disable=too-few-public-methods class LocalLogger: # pylint: disable=too-few-public-methods
linux = False linux = False
windows = True windows = True
serviceLogger = False
logger: typing.Optional[logging.Logger] logger: typing.Optional[logging.Logger]