diff --git a/app/controllers/admin/university/apps_controller.rb b/app/controllers/admin/university/apps_controller.rb index 7f1bf3d0de7470bec9d5ece7d2176a417c586391..e138c615cf49bb55d49b6d109d337fa0a1ba7953 100644 --- a/app/controllers/admin/university/apps_controller.rb +++ b/app/controllers/admin/university/apps_controller.rb @@ -9,6 +9,7 @@ class Admin::University::AppsController < Admin::University::ApplicationControll end def show + @should_display_token = @app.display_token! breadcrumb end diff --git a/app/models/university/app.rb b/app/models/university/app.rb index 3ecc928345d95ff3149ed84772c4b06f9a935436..24e3573866e41677220e51fea975fa9acdd7879b 100644 --- a/app/models/university/app.rb +++ b/app/models/university/app.rb @@ -30,6 +30,12 @@ class University::App < ApplicationRecord scope :ordered, -> { order(:name) } + def display_token! + return false if token_was_displayed? + update(token_was_displayed: true) + true + end + def regenerate_token! update(token: nil, token_was_displayed: false) end diff --git a/app/views/admin/university/apps/show.html.erb b/app/views/admin/university/apps/show.html.erb index 456a644a345b11bfea220c839c74a22e3c778a02..e368793a356a52093fc5b588d3621f9954c06987 100644 --- a/app/views/admin/university/apps/show.html.erb +++ b/app/views/admin/university/apps/show.html.erb @@ -1,9 +1,13 @@ <% content_for :title, @app %> +<% if @should_display_token %> + <p class="text-danger"><%= t('university.apps.token_display_notice') %></p> +<% end %> + <div class="row"> <div class="col-lg-6"> <%= osuny_label University::App.human_attribute_name('token') %> - <input type="string" value="<%= @app.token %>" class="form-control" disabled> + <input type="string" value="<%= @should_display_token ? @app.token : masked_string(@app.token) %>" class="form-control" disabled> </div> </div> diff --git a/config/locales/university/en.yml b/config/locales/university/en.yml index 3eb6096b1a365db9522e8efcee1b84e4fa90beee..35cdf08c207ab3dfc836b1ff28a8f45a071df8c4 100644 --- a/config/locales/university/en.yml +++ b/config/locales/university/en.yml @@ -208,7 +208,9 @@ en: import_btn: Import cohorts import_hint_html: "Possible values for <i>gender</i> are: m (male), f (female) and n (non binary).<br><i>Phone_professional</i>, <i>phone_personal</i>, <i>mobile</i> and <i>zipcode</i> fields must have a text format, not numbers.<br><i>Country</i> field must contain the ISO 3166 code of the country, so 2 upcase characters (<a href=\"https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes\" target=\_blank\">list</a>).<br><i>Social_twitter</i> field should have no @.<br><i>School</i> field should contain the internal school id.<br><i>Program</i> field should contain the internal program id." title: Cohorts imports - contributing: + apps: + token_display_notice: Make sure to store your token somewhere safe. You won’t be able to see it again! + contributing: one: contributing university other: contributing universities contributions_total: Contributions (total) diff --git a/config/locales/university/fr.yml b/config/locales/university/fr.yml index b255321a9d35b9867df8375faa3488689d259f48..da2f149e8c80d9f26f5899b103e47f95606df207 100644 --- a/config/locales/university/fr.yml +++ b/config/locales/university/fr.yml @@ -208,7 +208,9 @@ fr: import_btn: Importer des promotions import_hint_html: "Les valeurs pour <i>gender</i> peuvent être m (masculin), f (féminin) et n (non binaire).<br>Les champs <i>phone_professional</i>, <i>phone_personal</i>, <i>mobile</i> et <i>zipcode</i> doivent être au format texte, pas nombre.<br>Le champ <i>country</i> doit contenir le code ISO 3166 du pays, sur 2 caratères en majuscule (<a href=\"https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes\" target=\_blank\">liste</a>)<br>Le champ <i>social_twitter</i> ne doit pas contenir d'@.<br>Le champ <i>school</i> doit contenir l'id interne de l'école.<br>Le champ <i>program</i> doit contenir l'id interne de la formation." title: Imports de promotions - contributing: + apps: + token_display_notice: Assurez-vous de stocker votre jeton secret de manière sécurisée. Vous ne pourrez pas le revoir ! + contributing: one: université contributrice other: universités contributrices contributions_total: Contributions (total)