Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_misc_account.py @ 4341:e9971a4b0627
remove uses of twisted.internet.defer.returnValue
This function has been deprecated in Twisted 24.7.0.
author | Povilas Kanapickas <povilas@radix.lt> |
---|---|
date | Wed, 11 Dec 2024 01:17:09 +0200 |
parents | 0d7bb4df2343 |
children |
comparison
equal
deleted
inserted
replaced
4340:ea72364131d5 | 4341:e9971a4b0627 |
---|---|
423 ) | 423 ) |
424 | 424 |
425 @defer.inlineCallbacks | 425 @defer.inlineCallbacks |
426 def verify(attempt): | 426 def verify(attempt): |
427 auth = yield PasswordHasher.verify(attempt, sat_cipher) | 427 auth = yield PasswordHasher.verify(attempt, sat_cipher) |
428 defer.returnValue(auth) | 428 return auth |
429 | 429 |
430 def error_ui(message=None): | 430 def error_ui(message=None): |
431 if not message: | 431 if not message: |
432 message = D_("The provided profile password doesn't match.") | 432 message = D_("The provided profile password doesn't match.") |
433 error_ui = xml_tools.XMLUI("popup", title=D_("Attempt failure")) | 433 error_ui = xml_tools.XMLUI("popup", title=D_("Attempt failure")) |
441 delete_checkbox = data[xml_tools.SAT_FORM_PREFIX + 'delete_checkbox'] | 441 delete_checkbox = data[xml_tools.SAT_FORM_PREFIX + 'delete_checkbox'] |
442 if delete_checkbox == 'true': | 442 if delete_checkbox == 'true': |
443 verified = yield verify(delete_passwd) | 443 verified = yield verify(delete_passwd) |
444 assert isinstance(verified, bool) | 444 assert isinstance(verified, bool) |
445 if verified: | 445 if verified: |
446 defer.returnValue(self.__delete_account(profile)) | 446 return self.__delete_account(profile) |
447 defer.returnValue(error_ui()) | 447 return error_ui() |
448 | 448 |
449 # check for blog posts deletion | 449 # check for blog posts deletion |
450 if 'GROUPBLOG' in self.host.plugins: | 450 if 'GROUPBLOG' in self.host.plugins: |
451 delete_posts_passwd = data[xml_tools.SAT_FORM_PREFIX + 'delete_posts_passwd'] | 451 delete_posts_passwd = data[xml_tools.SAT_FORM_PREFIX + 'delete_posts_passwd'] |
452 delete_posts_checkbox = data[xml_tools.SAT_FORM_PREFIX + 'delete_posts_checkbox'] | 452 delete_posts_checkbox = data[xml_tools.SAT_FORM_PREFIX + 'delete_posts_checkbox'] |
455 comments = delete_comments_checkbox == 'true' | 455 comments = delete_comments_checkbox == 'true' |
456 if posts or comments: | 456 if posts or comments: |
457 verified = yield verify(delete_posts_passwd) | 457 verified = yield verify(delete_posts_passwd) |
458 assert isinstance(verified, bool) | 458 assert isinstance(verified, bool) |
459 if verified: | 459 if verified: |
460 defer.returnValue(self.__delete_blog_posts(posts, comments, profile)) | 460 return self.__delete_blog_posts(posts, comments, profile) |
461 defer.returnValue(error_ui()) | 461 return error_ui() |
462 """ | 462 """ |
463 | 463 |
464 # check for password modification | 464 # check for password modification |
465 current_passwd = data[xml_tools.SAT_FORM_PREFIX + "current_passwd"] | 465 current_passwd = data[xml_tools.SAT_FORM_PREFIX + "current_passwd"] |
466 new_passwd1 = data[xml_tools.SAT_FORM_PREFIX + "new_passwd1"] | 466 new_passwd1 = data[xml_tools.SAT_FORM_PREFIX + "new_passwd1"] |
469 verified = yield verify(current_passwd) | 469 verified = yield verify(current_passwd) |
470 assert isinstance(verified, bool) | 470 assert isinstance(verified, bool) |
471 if verified: | 471 if verified: |
472 if new_passwd1 == new_passwd2: | 472 if new_passwd1 == new_passwd2: |
473 data = yield self.__change_password(new_passwd1, profile=profile) | 473 data = yield self.__change_password(new_passwd1, profile=profile) |
474 defer.returnValue(data) | 474 return data |
475 else: | 475 else: |
476 defer.returnValue( | 476 return error_ui( |
477 error_ui( | 477 D_("The values entered for the new password are not equal.") |
478 D_("The values entered for the new password are not equal.") | |
479 ) | |
480 ) | 478 ) |
481 defer.returnValue(error_ui()) | 479 return error_ui() |
482 | 480 |
483 defer.returnValue({}) | 481 return {} |
484 | 482 |
485 def __change_password(self, password, profile): | 483 def __change_password(self, password, profile): |
486 """Ask for a confirmation before changing the XMPP account and SàT profile passwords. | 484 """Ask for a confirmation before changing the XMPP account and SàT profile passwords. |
487 | 485 |
488 @param password (str): the new password | 486 @param password (str): the new password |