This commit is contained in:
aitzol 2023-11-24 23:31:01 +01:00
parent a53f2aa274
commit 3a88b7db3b
9 changed files with 80 additions and 13 deletions

View File

@ -17,7 +17,6 @@
% if data['secureAuth'] == True: % if data['secureAuth'] == True:
<div class="info">{{ str['2fa-info-1'] }}</div> <div class="info">{{ str['2fa-info-1'] }}</div>
<div class="qr-code"> <div class="qr-code">
<img src="{{'static/tmp/'+data['authToken']+'.png'}}" /> <img src="{{'static/tmp/'+data['authToken']+'.png'}}" />
</div> </div>

20
app.py
View File

@ -169,8 +169,10 @@ def post_user():
logout(form('username')) logout(form('username'))
return index_tpl(two_factor_authentication=True, path=data_to_url, str=i18n.str) return index_tpl(two_factor_authentication=True, path=data_to_url, str=i18n.str)
except Error as e: 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) return user_tpl(alerts=[('success', '%s %s' % (i18n.msg[1], form('username').capitalize()), 'fadeOut' )], data=newSession().get(), str=i18n.str)
@post('/user/<path>') @post('/user/<path>')
@ -255,7 +257,7 @@ def post_signup():
return error(i18n.msg[15]) return error(i18n.msg[15])
if not tools.pwd_validation(form('password')): 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'): elif form('password') != form('confirm-password'):
return error(i18n.msg[7]) return error(i18n.msg[7])
@ -345,12 +347,12 @@ def post_enable_2fa():
except Error as e: except Error as e:
reload(newSession().get()['username'], None, None) reload(newSession().get()['username'], None, None)
LOG.warning(e) LOG.warning(e)
return error('2 urratseko autentifikazioa birgaitua izan da.') return error(i18n.msg[30])
except Error as e: except Error as e:
LOG.warning(e) LOG.warning(e)
return index_tpl(alerts=[('error', e, 'fadeOut')], str=i18n.str) 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') @post('/disable_2fa')
def post_disable_2fa(): def post_disable_2fa():
@ -371,7 +373,7 @@ def post_disable_2fa():
LOG.warning(e) LOG.warning(e)
return index_tpl(alerts=[('error', e, 'fadeOut')], str=i18n.str) 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') @post('/change_pwd')
def post_change_pwd(): def post_change_pwd():
@ -476,7 +478,7 @@ def connect_ldap(conf, **kwargs):
@error(404) @error(404)
@error(405) @error(405)
def error404(error): def error40x(error):
return index_tpl(str=i18n.str) return index_tpl(str=i18n.str)
#LOGIN #LOGIN
@ -812,7 +814,7 @@ def add_auth_attribute_step2(conf, *args):
except LDAPNoSuchAttributeResult as e: except LDAPNoSuchAttributeResult as e:
LOG.error('{}: {!s}'.format(e.__class__.__name__, 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: except LDAPExceptionError as e:
LOG.error('{}: {!s}'.format(e.__class__.__name__, e)) LOG.error('{}: {!s}'.format(e.__class__.__name__, e))
@ -1111,8 +1113,6 @@ def newSession():
def __init__(self): def __init__(self):
super(Session, self).__init__() super(Session, self).__init__()
self.data = bottle.request.environ.get('beaker.session') self.data = bottle.request.environ.get('beaker.session')
#self.id = None
#self.lang = self.get_lang()
#localization #localization
self.lang = self.get_lang() self.lang = self.get_lang()
global i18n global i18n

View File

@ -78,6 +78,12 @@ class LocalizeTo(object):
msg_27 = _("The session has expired.") msg_27 = _("The session has expired.")
msg_28 = _("Registration is currently closed. We apologize for the inconvenience.") 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, 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, '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, '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, '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, '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} '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)

View File

@ -270,3 +270,23 @@ msgstr "The session has expired."
#: libs/localization.py:73 #: libs/localization.py:73
msgid "Registration is currently closed. We apologize for the inconvenience." msgid "Registration is currently closed. We apologize for the inconvenience."
msgstr "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."

Binary file not shown.

View File

@ -270,3 +270,23 @@ msgstr "The session has expired."
#: libs/localization.py:73 #: libs/localization.py:73
msgid "Registration is currently closed. We apologize for the inconvenience." msgid "Registration is currently closed. We apologize for the inconvenience."
msgstr "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."

Binary file not shown.

View File

@ -266,3 +266,23 @@ msgstr "Saioa iraungi egin da."
#: libs/localization.py:73 #: libs/localization.py:73
msgid "Registration is currently closed. We apologize for the inconvenience." msgid "Registration is currently closed. We apologize for the inconvenience."
msgstr "Izen-ematea itxita dago une honetan. Barkatu eragozpenak." 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."

View File

@ -55,7 +55,7 @@
<div class="grid-item"> <div class="grid-item">
<div class="account"> <div class="account">
<h5>2FA</h5> <h5>2FA</h5>
<p>Bi urratseko autentifikazioa</p> <p>{{ str['2fa-title'] }}</p>
</div> </div>
</div> </div>