mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Buttons to disable two-factor authentication now work again (and show proper warning confirmation)
This commit is contained in:
parent
93d817db81
commit
4fa8eef1bf
3 changed files with 31 additions and 4 deletions
|
@ -10,6 +10,33 @@ export default class extends Controller
|
|||
this._confirmed = false;
|
||||
}
|
||||
|
||||
click(event) {
|
||||
//If a user has not already confirmed the deletion, just let turbo do its work
|
||||
if(this._confirmed) {
|
||||
this._confirmed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
const message = this.element.dataset.deleteMessage;
|
||||
const title = this.element.dataset.deleteTitle;
|
||||
|
||||
const that = this;
|
||||
|
||||
const confirm = bootbox.confirm({
|
||||
message: message, title: title, callback: function (result) {
|
||||
//If the dialog was confirmed, then submit the form.
|
||||
if (result) {
|
||||
that._confirmed = true;
|
||||
event.target.click();
|
||||
} else {
|
||||
that._confirmed = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
submit(event) {
|
||||
//If a user has not already confirmed the deletion, just let turbo do its work
|
||||
if(this._confirmed) {
|
||||
|
|
|
@ -68,8 +68,8 @@
|
|||
{% endif %}
|
||||
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('reset_2fa' ~ entity.id) }}">
|
||||
<button class="btn btn-warning" {% if tfa_disable_disabled %}disabled="disabled"{% endif %}
|
||||
data-delete-btn data-title="{% trans %}user.edit.tfa.disable_tfa_title{% endtrans %}" data-message="{% trans %}user.edit.tfa.disable_tfa_message{% endtrans %}"
|
||||
<button class="btn btn-warning" {% if tfa_disable_disabled %}disabled="disabled"{% endif %} {{ stimulus_controller('elements/delete_btn') }} {{ stimulus_action('elements/delete_btn', 'click') }}
|
||||
data-delete-btn data-delete-title="{% trans %}user.edit.tfa.disable_tfa_title{% endtrans %}" data-delete-message="{% trans %}user.edit.tfa.disable_tfa_message{% endtrans %}"
|
||||
type="submit" name="reset_2fa" value="reset_2fa">{% trans %}user.edit.tfa.disable_tfa.btn{% endtrans %}</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
{% set google_form_attr = {} %}
|
||||
{% if tfa_google.enabled %}
|
||||
{% set google_form_attr = { 'data-delete-form': true, 'data-controller': 'elements--delete-btn', 'data-action': 'submit->elements--delete-btn#submit',
|
||||
'data-title': 'tfa_google.disable.confirm_title' | trans, 'data-message': 'tfa_google.disable.confirm_message'|trans} %}
|
||||
'data-delete-title': 'tfa_google.disable.confirm_title' | trans, 'data-delete-message': 'tfa_google.disable.confirm_message'|trans} %}
|
||||
{% endif %}
|
||||
|
||||
{{ form_start(google_form, { 'attr': google_form_attr}) }}
|
||||
|
@ -85,7 +85,7 @@
|
|||
</div>
|
||||
{% else %}
|
||||
{% set backup_form_attr = { 'data-delete-form': true, 'data-controller': 'elements--delete-btn', 'data-action': 'submit->elements--delete-btn#submit',
|
||||
'data-title': 'tfa_backup.reset_codes.confirm_title' | trans, 'data-message': 'tfa_backup.reset_codes.confirm_message' | trans} %}
|
||||
'data-delete-title': 'tfa_backup.reset_codes.confirm_title' | trans, 'data-delete-message': 'tfa_backup.reset_codes.confirm_message' | trans} %}
|
||||
{{ form_start(backup_form, { 'attr': backup_form_attr}) }}
|
||||
<div class="offset-sm-3">
|
||||
<h6>{% trans %}tfa_backup.enabled{% endtrans %}</h6>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue