Browse Source

增加前端邮箱正则限制

pull/4/head
欧醚 4 years ago
parent
commit
54cf68d8c6
3 changed files with 6 additions and 3 deletions
  1. +2
    -1
      app/views/about/_registration.html.haml
  2. +2
    -1
      app/views/auth/registrations/new.html.haml
  3. +2
    -1
      config/initializers/new_features.rb

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

@ -7,7 +7,8 @@
= 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'), pattern: '[a-zA-Z0-9_]+', maxlength: 30 }, append: "(@#{site_hostname})", hint: false, disabled: closed_registrations?
- email_domain = Rails.configuration.x.email_default_domain
= f.input :email, wrapper: :with_label, label: false, required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email'), :autocomplete => 'off', placeholder: t('simple_form.labels.defaults.email') }, append: "@#{email_domain}", hint: false, disabled: closed_registrations?
- email_regex = Rails.configuration.x.email_regex
= f.input :email, placeholder: t('simple_form.labels.defaults.email'), wrapper: :with_label, label: false, required: true, input_html: { 'aria-label' => t('simple_form.labels.defaults.email'), :autocomplete => 'off', pattern: "#{email_regex}" }, 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', :minlength => User.password_length.first, :maxlength => User.password_length.last }, 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

@ -18,7 +18,8 @@
.fields-group
- 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' }, append: "@#{email_domain}"
- email_regex = Rails.configuration.x.email_regex
= 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', pattern: "#{email_regex}" }, 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', :minlength => User.password_length.first, :maxlength => User.password_length.last }

+ 2
- 1
config/initializers/new_features.rb View File

@ -1,7 +1,8 @@
# frozen_string_literal: true
Rails.application.configure do
config.x.email_default_domain = ENV.fetch('EMAIL_DEFAULT_DOMAIN') { '???.edu.cn' }
config.x.email_default_domain = ENV.fetch('EMAIL_DEFAULT_DOMAIN') { '' }
config.x.email_regex = ENV.fetch('EMAIL_REGEX') { '.+' }
config.x.tree_address = ENV.fetch('TREE_ADDRESS') {''}
config.x.tree_acc = ENV.fetch('TREE_ACC') {'0'}
config.x.anon.tag = ENV.fetch('ANON_TAG') {'[mask]'}

Loading…
Cancel
Save