Browse Source

set default email domain in ENV

pull/4/head
欧醚 5 years ago
parent
commit
3142db432d
4 changed files with 8 additions and 5 deletions
  1. +2
    -3
      app/views/about/_registration.html.haml
  2. +2
    -1
      app/views/auth/registrations/new.html.haml
  3. +1
    -0
      config/initializers/blacklists.rb
  4. +3
    -1
      public/auto_comp_email.js

+ 2
- 3
app/views/about/_registration.html.haml View File

@ -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?

+ 2
- 1
app/views/auth/registrations/new.html.haml View File

@ -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' }

+ 1
- 0
config/initializers/blacklists.rb View File

@ -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

+ 3
- 1
public/auto_comp_email.js View File

@ -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) {

Loading…
Cancel
Save