Changesets can be listed by changeset number.
The Git repository is here.
Changeset 482
Improved robot/spammer rejection code for signups
- Comitted by: rool
- Date: Sunday November 19 23:14:50 2023 (11 months ago)
Affected files:
rool/rails/hub/trunk/app/controllers/account_controller.rb:
prev. | current | |
layout 'default.html.erb' | ||
17 | PROHIBITED_EMAIL_DOMAINS = %w{ | |
18 | .cn | |
19 | .kr | |
20 | .ru | |
21 | } | |
22 | ||
23 | GOOGLE_EMAIL_DOMAINS = %w{ | |
24 | gmail.com | |
25 | googlemail.com | |
26 | google.com | |
27 | } | |
28 | ||
29 | PROHIBITED_GOOGLE_PREFIXES = %w{ | |
30 | johnnyjohnson3445 | |
31 | } | |
32 | ||
# Cache the logged in and out PNG images in RAM; they're only small. | ||
@@logged_in_image = File.read("#{RAILS_ROOT}/public/images/icons/logged_in.png") | ||
... | ... | |
# Bulk assignment from the params hash is safe because the User object | ||
# contains nothing that won't be overwritten anyway or isn't already | ||
# protected by attr_accessible in the User model. | ||
137 | # | |
138 | @user = User.new(params[:user]) | |
139 | error = nil | |
122 | | |
123 | | |
141 | if @user.email.blank? | |
142 | error = 'An e-mail address must be provided.' | |
143 | else | |
144 | @user.email = @user.email.strip() | |
145 | lower_email = @user.email.downcase() | |
146 | is_prohibited = PROHIBITED_EMAIL_DOMAINS.any? { | domain | lower_email.end_with?(domain) } | |
147 | is_google_domain = GOOGLE_EMAIL_DOMAINS.any? { | domain | lower_email.end_with?(domain) } unless is_prohibited | |
125 | | |
126 | | |
149 | if is_google_domain | |
150 | canonical_lower_email = lower_email.gsub('.', '') | |
151 | lower_email_prefix = canonical_lower_email.gsub(/[+@].*$/, '') | |
152 | is_prohibited = PROHIBITED_GOOGLE_PREFIXES.any? { | prefix | prefix == lower_email_prefix } | |
153 | end | |
154 | ||
155 | if is_prohibited | |
156 | error = 'Due to overwhelming spam volumes from some locations, self-signups for those locations are blocked. Please contact ROOL for assistance.' | |
157 | end | |
158 | end | |
159 | ||
160 | if error.present? | |
161 | hubssolib_set_flash(:attention, error) | |
redirect_to :controller => 'tasks', :action => nil | ||
128 | | |
163 | return # NOTE EARLY EXIT | |
end | ||
# Are there any users yet? If not, grant this user admin permissions. |