changeset 7fca1baab0c0 in modules/authentication_sms:default
details:
https://hg.tryton.org/modules/authentication_sms?cmd=changeset;node=7fca1baab0c0
description:
Show password field if password_sms is an authentication method
issue9255
review289921108
diffstat:
res.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diffs (28 lines):
diff -r 998b4830bf8a -r 7fca1baab0c0 res.py
--- a/res.py Thu Mar 19 19:03:09 2020 +0100
+++ b/res.py Sat Apr 25 09:44:32 2020 +0200
@@ -9,9 +9,12 @@
from trytond.i18n import gettext
from trytond.model import ModelSQL, fields
from trytond.pool import PoolMeta, Pool
+from trytond.pyson import Eval
from trytond.tools import resolve
logger = logging.getLogger(__name__)
+_has_password_sms = 'password_sms' in config.get(
+ 'session', 'authentications', default='password').split(',')
def send_sms(text, to):
@@ -33,6 +36,11 @@
def __setup__(cls):
super(User, cls).__setup__()
cls._preferences_fields.append('mobile')
+ cls._buttons['reset_password']['invisible'] &= (
+ ~Eval('email', True) | (not _has_password_sms))
+ cls.password.states['invisible'] &= not _has_password_sms
+ cls.password_reset.states['invisible'] &= not _has_password_sms
+ cls.password_reset_expire.states['invisible'] &= not _has_password_sms
@classmethod
def _login_sms(cls, login, parameters):