From 7b766af87e917f887655bdba0c9af6ee7d3fdce1 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Jan 14 2023 04:03:16 +0000 Subject: fix(user_settings): unable to change default email If more then two email addresses are defined in the user settings, it was not possible to change the default address to one of those additional addresses. This was caused by the frontend, all addresses got the same html 'form-id', that way always the first one was submitted when clicking the submit button, independent of the actual selected email address. Resolved by adding a random number as suffix to the 'form-id' of each email address, that way there are unique and the default mail address can be changed even with more then two assigned addresses. Fixes: https://pagure.io/pagure/issue/5327 Fixes: https://pagure.io/pagure/issue/5338 --- diff --git a/pagure/templates/user_settings.html b/pagure/templates/user_settings.html index d68b541..01c43bc 100644 --- a/pagure/templates/user_settings.html +++ b/pagure/templates/user_settings.html @@ -7,6 +7,7 @@ {% set tag = "users"%} {% macro render_email(email, form, validated=True) %} +{% set random_number = range(0, 256) | random() %}
 {{ email.email }} {% if validated %} @@ -25,11 +26,11 @@
{% else %}
+ action="{{ url_for('ui_ns.set_default_email') }}" id="default_mail_{{ random_number }}"> {{ form.csrf_token }} + data-form-id="default_mail_{{ random_number }}" title="Set as default email address">