Commit 4a0ec8b5e177042a1bfcaba068e4e1118705a1da
Committed by
Daniela Feitosa
1 parent
610e3552
Exists in
master
and in
29 other branches
Fix usp_id match
Showing
2 changed files
with
6 additions
and
2 deletions
Show diff stats
plugins/stoa/lib/stoa_plugin.rb
... | ... | @@ -60,12 +60,14 @@ class StoaPlugin < Noosfero::Plugin |
60 | 60 | end |
61 | 61 | |
62 | 62 | def account_controller_filters |
63 | + environment = context.environment | |
63 | 64 | block = lambda do |
64 | 65 | params[:profile_data] ||= {} |
65 | 66 | params[:profile_data][:invitation_code] = params[:invitation_code] |
67 | + invitation = Task.pending.find(:first, :conditions => {:code => params[:invitation_code]}) | |
66 | 68 | if request.post? |
67 | - if !params[:invitation_code] && !StoaPlugin::UspUser.matches?(params[:profile_data][:usp_id], params[:confirmation_field], params[params[:confirmation_field]]) | |
68 | - @person = Person.new | |
69 | + if !invitation && !StoaPlugin::UspUser.matches?(params[:profile_data][:usp_id], params[:confirmation_field], params[params[:confirmation_field]]) | |
70 | + @person = Person.new(:environment => environment) | |
69 | 71 | @person.errors.add(:usp_id, _(' validation failed')) |
70 | 72 | render :action => :signup |
71 | 73 | end | ... | ... |
plugins/stoa/lib/stoa_plugin/usp_user.rb
... | ... | @@ -13,6 +13,8 @@ class StoaPlugin::UspUser < ActiveRecord::Base |
13 | 13 | end |
14 | 14 | |
15 | 15 | def self.matches?(usp_id, field, value) |
16 | + usp_id.gsub!(/[.-]/,'') | |
17 | + value.gsub!(/[.-]/,'') | |
16 | 18 | user = StoaPlugin::UspUser.find_by_codpes(usp_id.to_i) |
17 | 19 | return false if user.nil? || !user.respond_to?(field) || value.blank? |
18 | 20 | case field.to_sym | ... | ... |