From 3142db432d155fc2397585703a4b8eeaba648bc2 Mon Sep 17 00:00:00 2001 From: Z Date: Fri, 25 Oct 2019 15:28:33 +0800 Subject: [PATCH] set default email domain in ENV --- app/views/about/_registration.html.haml | 5 ++--- app/views/auth/registrations/new.html.haml | 3 ++- config/initializers/blacklists.rb | 1 + public/auto_comp_email.js | 4 +++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/views/about/_registration.html.haml b/app/views/about/_registration.html.haml index 93c08bf92..2699db368 100644 --- a/app/views/about/_registration.html.haml +++ b/app/views/about/_registration.html.haml @@ -6,9 +6,8 @@ = f.simple_fields_for :account do |account_fields| = account_fields.input :username, wrapper: :with_label, label: false, required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.username'), :autocomplete => 'off', placeholder: t('simple_form.labels.defaults.username') }, append: "(@#{site_hostname})", hint: false, disabled: closed_registrations? - /= f.input :email, placeholder: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email'), :autocomplete => 'off' }, hint: false, disabled: closed_registrations? - - = f.input :email, wrapper: :with_label, label: false, placeholder: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email'), :autocomplete => 'off', :type => 'text' }, append: "@mails.tsinghua.edu.cn", hint: false, disabled: closed_registrations? + - email_domain = Rails.configuration.x.email_default_domain + = f.input :email, wrapper: :with_label, label: false, placeholder: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email'), :autocomplete => 'off', :type => 'text' }, append: "@#{email_domain}", hint: false, disabled: closed_registrations? = f.input :password, placeholder: t('simple_form.labels.defaults.password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.password'), :autocomplete => 'off' }, hint: false, disabled: closed_registrations? = f.input :password_confirmation, placeholder: t('simple_form.labels.defaults.confirm_password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_password'), :autocomplete => 'off' }, hint: false, disabled: closed_registrations? diff --git a/app/views/auth/registrations/new.html.haml b/app/views/auth/registrations/new.html.haml index 52cf9535d..520a474aa 100644 --- a/app/views/auth/registrations/new.html.haml +++ b/app/views/auth/registrations/new.html.haml @@ -17,7 +17,8 @@ = ff.input :username, wrapper: :with_label, autofocus: true, label: t('simple_form.labels.defaults.username'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.username'), :autocomplete => 'off' }, append: "(@#{site_hostname})", hint: t('simple_form.hints.defaults.username', domain: site_hostname) .fields-group - = f.input :email, wrapper: :with_label, label: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email'), :autocomplete => 'off', :type => 'text' }, append: "@mails.tsinghua.edu.cn" + - email_domain = Rails.configuration.x.email_default_domain + = f.input :email, wrapper: :with_label, label: t('simple_form.labels.defaults.email'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email'), :autocomplete => 'off', :type => 'text' }, append: "@#{email_domain}" .fields-group = f.input :password, wrapper: :with_label, label: t('simple_form.labels.defaults.password'), required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.password'), :autocomplete => 'off' } diff --git a/config/initializers/blacklists.rb b/config/initializers/blacklists.rb index 020d84f56..ce6cb2d71 100644 --- a/config/initializers/blacklists.rb +++ b/config/initializers/blacklists.rb @@ -3,4 +3,5 @@ Rails.application.configure do config.x.email_domains_blacklist = ENV.fetch('EMAIL_DOMAIN_BLACKLIST') { 'mvrht.com' } config.x.email_domains_whitelist = ENV.fetch('EMAIL_DOMAIN_WHITELIST') { '' } + config.x.email_default_domain = ENV.fetch('EMAIL_DEFAULT_DOMAIN') { '???.edu.cn' } end diff --git a/public/auto_comp_email.js b/public/auto_comp_email.js index ece389079..aaddd3d04 100644 --- a/public/auto_comp_email.js +++ b/public/auto_comp_email.js @@ -1,4 +1,6 @@ -var em = document.getElementById("user_email"); +var em = document.getElementById("registration_user_email"); +if(!em) + em = document.getElementById("user_email"); var ap = em.nextSibling; em.addEventListener("blur", function( event ) { if(ap.style.display != 'none' && em.value) {