From 3a88b7db3b96fb518810fd158c5029594576019c Mon Sep 17 00:00:00 2001 From: aitzol Date: Fri, 24 Nov 2023 23:31:01 +0100 Subject: [PATCH] 2fa-1.4 --- _2fa.tpl | 1 - app.py | 20 ++++++++++---------- libs/localization.py | 10 +++++++++- locales/base.pot | 20 ++++++++++++++++++++ locales/en/LC_MESSAGES/base.mo | Bin 5439 -> 6009 bytes locales/en/LC_MESSAGES/base.po | 20 ++++++++++++++++++++ locales/eu/LC_MESSAGES/base.mo | Bin 5572 -> 6160 bytes locales/eu/LC_MESSAGES/base.po | 20 ++++++++++++++++++++ user.tpl | 2 +- 9 files changed, 80 insertions(+), 13 deletions(-) diff --git a/_2fa.tpl b/_2fa.tpl index 742f071..5df3b3c 100644 --- a/_2fa.tpl +++ b/_2fa.tpl @@ -17,7 +17,6 @@ % if data['secureAuth'] == True:
{{ str['2fa-info-1'] }}
-
diff --git a/app.py b/app.py index 675464e..0c2a310 100644 --- a/app.py +++ b/app.py @@ -169,8 +169,10 @@ def post_user(): logout(form('username')) return index_tpl(two_factor_authentication=True, path=data_to_url, str=i18n.str) except Error as e: - LOG.warning("Erabiltzailea ez da aurkitu???") - + #On error force disable 2fa + add_auth_attribute_step1(form('username'), None, action='disable') + LOG.debug("Two factor authentication has been impossible.") + return error(i18n.msg[29]) return user_tpl(alerts=[('success', '%s %s' % (i18n.msg[1], form('username').capitalize()), 'fadeOut' )], data=newSession().get(), str=i18n.str) @post('/user/') @@ -255,7 +257,7 @@ def post_signup(): return error(i18n.msg[15]) if not tools.pwd_validation(form('password')): - return error(i18n.msg[8]) #mezua ALDATU egin behar da + return error(i18n.msg[8]) elif form('password') != form('confirm-password'): return error(i18n.msg[7]) @@ -345,12 +347,12 @@ def post_enable_2fa(): except Error as e: reload(newSession().get()['username'], None, None) LOG.warning(e) - return error('2 urratseko autentifikazioa birgaitua izan da.') + return error(i18n.msg[30]) except Error as e: LOG.warning(e) return index_tpl(alerts=[('error', e, 'fadeOut')], str=i18n.str) - return _2fa_tpl(alerts=[('success', 'Bikain, 2 urratseko autentifikazioa gaitu da.', 'fadeOut')], data=newSession().get(), str=i18n.str) + return _2fa_tpl(alerts=[('success', i18n.msg[31], 'fadeOut')], data=newSession().get(), str=i18n.str) @post('/disable_2fa') def post_disable_2fa(): @@ -371,7 +373,7 @@ def post_disable_2fa(): LOG.warning(e) return index_tpl(alerts=[('error', e, 'fadeOut')], str=i18n.str) - return _2fa_tpl(alerts=[('error', '2 urratseko autentifikazioa desgaitua izan da.', 'fadeOut')], data=newSession().get(), str=i18n.str) + return _2fa_tpl(alerts=[('error', i18n.msg[32], 'fadeOut')], data=newSession().get(), str=i18n.str) @post('/change_pwd') def post_change_pwd(): @@ -476,7 +478,7 @@ def connect_ldap(conf, **kwargs): @error(404) @error(405) -def error404(error): +def error40x(error): return index_tpl(str=i18n.str) #LOGIN @@ -812,7 +814,7 @@ def add_auth_attribute_step2(conf, *args): except LDAPNoSuchAttributeResult as e: LOG.error('{}: {!s}'.format(e.__class__.__name__, e)) - raise Error('Dagoeneko desgaiturik zeneukan 2 urratseko autentifikazioa.') + raise Error(i18n.msg[33]) except LDAPExceptionError as e: LOG.error('{}: {!s}'.format(e.__class__.__name__, e)) @@ -1111,8 +1113,6 @@ def newSession(): def __init__(self): super(Session, self).__init__() self.data = bottle.request.environ.get('beaker.session') - #self.id = None - #self.lang = self.get_lang() #localization self.lang = self.get_lang() global i18n diff --git a/libs/localization.py b/libs/localization.py index a47b0db..6223fe0 100644 --- a/libs/localization.py +++ b/libs/localization.py @@ -78,6 +78,12 @@ class LocalizeTo(object): msg_27 = _("The session has expired.") msg_28 = _("Registration is currently closed. We apologize for the inconvenience.") + msg_29 = _("Two factor authentication has been impossible.") + msg_30 = _("Two factor authentication has been restored.") + msg_31 = _("Two factor authentication has been enabled.") + msg_32 = _("Two factor authentication has been disabled.") + msg_33 = _("Two factor authentication was already disabled.") + self.str = {'usr':str_00, 'usrn':str_01, 'fn':str_02, 'sn':str_03, 'pwd':str_04, 'old-pwd':str_05, 'new-pwd':str_06, 'conf-pwd':str_07, 'email':str_08, 'edit':str_09, 'login':str_10, 'log-out':str_11, 'del':str_12, 'sign-up':str_13, 'back':str_14, 'update':str_15, 'or-sign-in':str_16, @@ -85,4 +91,6 @@ class LocalizeTo(object): 'del-account':str_22, 'welcome':str_23, 'logs':str_24, 'last-login':str_25, 'devices':str_26, 'show':str_27, '2fa-title':str_28, 'token':str_29, 'disable':str_30, 'enable':str_31, '2fa-info-1':str_32, '2fa-info-2':str_33, 'pwd-pattern': msg_08} - self.msg = (msg_00, msg_01, msg_02, msg_03, msg_04, msg_05, msg_06, msg_07, msg_08, msg_09, msg_10, msg_11, msg_12, msg_13, msg_14, msg_15, msg_16, msg_17, msg_18, msg_19, msg_20, msg_21, msg_22, msg_23, msg_24, msg_25, msg_26, msg_27, msg_28) + self.msg = (msg_00, msg_01, msg_02, msg_03, msg_04, msg_05, msg_06, msg_07, msg_08, msg_09, msg_10, msg_11, + msg_12, msg_13, msg_14, msg_15, msg_16, msg_17, msg_18, msg_19, msg_20, msg_21, msg_22, msg_23, + msg_24, msg_25, msg_26, msg_27, msg_28, msg_29, msg_30, msg_31, msg_32, msg_33) diff --git a/locales/base.pot b/locales/base.pot index 892c2d4..7db3f29 100644 --- a/locales/base.pot +++ b/locales/base.pot @@ -270,3 +270,23 @@ msgstr "The session has expired." #: libs/localization.py:73 msgid "Registration is currently closed. We apologize for the inconvenience." msgstr "Registration is currently closed. We apologize for the inconvenience." + +#: libs/localization.py: +msgid "Two factor authentication has been impossible." +msgstr "Two factor authentication has been impossible." + +#: libs/localization.py: +msgid "Two factor authentication has been restored." +msgstr "Two factor authentication has been restored." + +#: libs/localization.py: +msgid "Two factor authentication has been enabled." +msgstr "Two factor authentication has been enabled." + +#: libs/localization.py: +msgid "Two factor authentication has been disabled." +msgstr "Two factor authentication has been disabled." + +#: libs/localization.py: +msgid "Two factor authentication was already disabled." +msgstr "Two factor authentication was already disabled." diff --git a/locales/en/LC_MESSA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9Cnh$0=$Zv=Qaje z-(GRC5Z~eye!~`=U^mL-9x9VZsM0@0=Cl%a;3r&(QOco>^x_%J;2M00Dg276K%8>O zz38YE=eW=UdCxnT^sz9i_cJx+@9V?m4K$#7-;SCnjoRojRPRrsHgeu`3~RZcMD>0e z)v7|6`m0p;d7$2ZKuz=uv*_bj6vK9*DzYD2(Ls{2Ye@2T3pHU8_4~)DgkB&y*c9`CBB5}{UoYqH?bR^p?d!tmFZx8*&V2ahETmfg*m)| z>U|UGYn~Kp!+RVq)cbung(Ij;8>yo*$)GaXhU$G5wXs9kfk#lizk=GxT~zNMpnAWB zAF21pQ5Bf>e2=PxQ$^jiK+>}hX}vWNO@u}pq21FJcj$c$l6U*rgE}W#urda?P^NuE zJE69z(whkO=8ko&?_Q|)y@WDS`8aRx&_AUAM}`|^xt35H(uBq=!cUNtdoI8h6U%ks z4OO!;=!R`@Z&+VtSzY-CRo?YPv-d2HDsjJeuXd?-Dyz diff --git a/locales/en/LC_MESSAGES/base.po b/locales/en/LC_MESSAGES/base.po index 82ef3c4..12412c7 100644 --- a/locales/en/LC_MESSAGES/base.po +++ b/locales/en/LC_MESSAGES/base.po @@ -270,3 +270,23 @@ msgstr "The session has expired." #: libs/localization.py:73 msgid "Registration is currently closed. We apologize for the inconvenience." msgstr "Registration is currently closed. We apologize for the inconvenience." + +#: libs/localization.py: +msgid "Two factor authentication has been impossible." +msgstr "Two factor authentication has been impossible." + +#: libs/localization.py: +msgid "Two factor authentication has been restored." +msgstr "Two factor authentication has been restored." + +#: libs/localization.py: +msgid "Two factor authentication has been enabled." +msgstr "Two factor authentication has been enabled." + +#: libs/localization.py: +msgid "Two factor authentication has been disabled." +msgstr "Two factor authentication has been disabled." + +#: libs/localization.py: +msgid "Two factor authentication was already disabled." +msgstr "Two factor authentication was already disabled." diff --git a/locales/eu/LC_MESSAGES/base.mo b/locales/eu/LC_MESSAGES/base.mo index a63c6887b790e0137eb5c127ad36cfcef1618520..2dafaf1993343ec36438696b309530ee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ly5HGdF;Vm_zII)Kvf_@ zIphgUs}vXLXn>sKQ*0|^U{t0{mCK3vs+QL_fLg;SZp9ANz9<*dI>K zSiz54F@@bYR73sspb1WlWz(qZJSSGczMyvhJZkN{tIawwj9S~1sDZMm3XEeNK12=l z0SD1bma4!oYMe3DL~o|)r~u5&uf z;X&Mjzc7Zi)LnZdg?j!eY{2v-I?8+!mC*}i>5JKFZ58@~X0OZ@+A9iGihQkwrYdQ( zl|tp!-cgeEG*v~FO3}!<7_EB$6^v=^G-ae$M>AHaGXF;p7fQC7mZ0sUDOS*2G$vcD z0@y}cSRE&{;Yz`(*xup=<2TXSS^5OEWB1Ua&bmOi3b7TMj diff --git a/locales/eu/LC_MESSAGES/base.po b/locales/eu/LC_MESSAGES/base.po index 3a70da0..0dd208e 100644 --- a/locales/eu/LC_MESSAGES/base.po +++ b/locales/eu/LC_MESSAGES/base.po @@ -266,3 +266,23 @@ msgstr "Saioa iraungi egin da." #: libs/localization.py:73 msgid "Registration is currently closed. We apologize for the inconvenience." msgstr "Izen-ematea itxita dago une honetan. Barkatu eragozpenak." + +#: libs/localization.py: +msgid "Two factor authentication has been impossible." +msgstr "Ezinezkoa izan da bi urratseko autentifikazioa burutzea." + +#: libs/localization.py: +msgid "Two factor authentication has been restored." +msgstr "Bi urratseko autentifikazioa birgaitua izan da." + +#: libs/localization.py: +msgid "Two factor authentication has been enabled." +msgstr "Bi urratseko autentifikazioa gaitua izan da." + +#: libs/localization.py: +msgid "Two factor authentication has been disabled." +msgstr "Bi urratseko autentifikazioa desgaitua izan da." + +#: libs/localization.py: +msgid "Two factor authentication was already disabled." +msgstr "Bi urratseko autentifikazioa desgaiturik zegoen." diff --git a/user.tpl b/user.tpl index 9737fa8..f2063ee 100644 --- a/user.tpl +++ b/user.tpl @@ -55,7 +55,7 @@