Skip to content
Snippets Groups Projects
Verified Commit cc52be1a authored by ornanovitch's avatar ornanovitch
Browse files

aller jusqu'au bout de la logique...

parent ff414181
No related branches found
No related tags found
No related merge requests found
...@@ -52,31 +52,31 @@ def totp(): ...@@ -52,31 +52,31 @@ def totp():
@blueprint.route("/totp/setup", methods=["GET", "POST"]) @blueprint.route("/totp/setup", methods=["GET", "POST"])
@security.authentication_required() @security.authentication_required()
@security.confirmation_required("Setup 2FA with TOTP") @security.confirmation_required("setup 2FA with TOTP")
def totp_setup(): def totp_setup():
user = flask_login.current_user user = flask_login.current_user
auth = models.Auth(models.Auth.TOTP) auth = models.Auth(models.Auth.TOTP)
auth.set_otp_key() auth.set_otp_key()
user.auths[models.Auth.TOTP] = auth user.auths[models.Auth.TOTP] = auth
models.log(models.History.MFA, comment=str(_("2FA has been enabled")), models.log(models.History.MFA, comment=str(_("2FA with TOTP has been enabled")),
user=flask_login.current_user) user=flask_login.current_user)
models.db.session.add(auth) models.db.session.add(auth)
models.db.session.commit() models.db.session.commit()
flask.flash(_("Successfully setup 2FA"), "success") flask.flash(_("Successfully setup 2FA with TOTP"), "success")
return flask.redirect(flask.url_for(".totp")) return flask.redirect(flask.url_for(".totp"))
@blueprint.route("/totp/delete", methods=["GET", "POST"]) @blueprint.route("/totp/delete", methods=["GET", "POST"])
@security.authentication_required() @security.authentication_required()
@security.confirmation_required("Delete 2FA with TOTP") @security.confirmation_required("delete 2FA with TOTP")
def totp_delete(): def totp_delete():
user = flask_login.current_user user = flask_login.current_user
auth = user.auths[models.Auth.TOTP] auth = user.auths[models.Auth.TOTP]
models.log(models.History.MFA, comment=str(_("2FA has been disabled")), models.log(models.History.MFA, comment=str(_("2FA with TOTP has been disabled")),
user=flask_login.current_user) user=flask_login.current_user)
models.db.session.delete(auth) models.db.session.delete(auth)
models.db.session.commit() models.db.session.commit()
flask.flash(_("Successfully disabled 2FA"), "success") flask.flash(_("Successfully disabled 2FA with TOTP"), "success")
return flask.redirect(flask.url_for(".totp")) return flask.redirect(flask.url_for(".totp"))
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
"create": "plus", "create": "plus",
"transition": "recycle", "transition": "recycle",
"password": "lock", "password": "lock",
"enable 2fa": "qrcode",
"mfa": "qrcode" "mfa": "qrcode"
}[event.category] }} bg-blue"></i> }[event.category] }} bg-blue"></i>
<div class="timeline-item"> <div class="timeline-item">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment