Description:
fixed user confirmation bug
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@305 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r160:0138848b0c5b - - 5 files changed: 42 inserted, 31 deleted
@@ -5,17 +5,17 | |||
|
5 | 5 | before_filter :authenticate, :except => [:index, :login] |
|
6 | 6 | before_filter :check_viewability, :except => [:index, :login] |
|
7 | 7 | |
|
8 | - # | |
|
9 | - # COMMENT OUT: filter in each action instead | |
|
10 | - # | |
|
11 | - # before_filter :verify_time_limit, :only => [:submit] | |
|
8 | + # COMMENTED OUT: filter in each action instead | |
|
9 | + # before_filter :verify_time_limit, :only => [:submit] | |
|
12 | 10 | |
|
13 | 11 | verify :method => :post, :only => [:submit], |
|
14 | 12 | :redirect_to => { :action => :index } |
|
15 | 13 | |
|
16 |
- |
|
|
17 |
- |
|
|
14 | + # COMMENT OUT: only need when having high load | |
|
15 | + # caches_action :index, :login | |
|
18 | 16 | |
|
17 | + # NOTE: This method is not actually needed, 'config/routes.rb' has | |
|
18 | + # assigned action login as a default action. | |
|
19 | 19 | def index |
|
20 | 20 | redirect_to :action => 'login' |
|
21 | 21 | end |
@@ -25,9 +25,17 | |||
|
25 | 25 | reset_session |
|
26 | 26 | flash[:notice] = saved_notice |
|
27 | 27 | |
|
28 | + # EXPERIMENT: | |
|
29 | + # Hide login if in single user mode and the url does not | |
|
30 | + # explicitly specify /login | |
|
28 | 31 | # |
|
29 | - # These are for site administrator login | |
|
30 | - # | |
|
32 | + # logger.info "PATH: #{request.path}" | |
|
33 | + # if Configuration['system.single_user_mode'] and | |
|
34 | + # request.path!='/main/login' | |
|
35 | + # @hidelogin = true | |
|
36 | + # end | |
|
37 | + | |
|
38 | + # Site administrator login | |
|
31 | 39 | @countries = Country.find(:all, :include => :sites) |
|
32 | 40 | @country_select = @countries.collect { |c| [c.name, c.id] } |
|
33 | 41 |
@@ -55,11 +55,11 | |||
|
55 | 55 | def confirm |
|
56 | 56 | login = params[:login] |
|
57 | 57 | key = params[:activation] |
|
58 | - user = User.find_by_login(login) | |
|
59 | - if (user) and (user.verify_activation_key(key)) | |
|
60 | - if user.valid? # check uniquenss of email | |
|
61 | - user.activated = true | |
|
62 | - user.save | |
|
58 | + @user = User.find_by_login(login) | |
|
59 | + if (@user) and (@user.verify_activation_key(key)) | |
|
60 | + if @user.valid? # check uniquenss of email | |
|
61 | + @user.activated = true | |
|
62 | + @user.save | |
|
63 | 63 | @result = :successful |
|
64 | 64 | else |
|
65 | 65 | @result = :email_used |
@@ -128,6 +128,7 | |||
|
128 | 128 | end |
|
129 | 129 | |
|
130 | 130 | def enough_time_interval_between_same_email_registrations |
|
131 | + return if !self.new_record? | |
|
131 | 132 | open_user = User.find_by_email(self.email, |
|
132 | 133 | :order => 'created_at DESC') |
|
133 | 134 | if open_user and open_user.created_at and |
@@ -8,26 +8,27 | |||
|
8 | 8 | |
|
9 | 9 | %b= Configuration['ui.front.welcome_message'] |
|
10 | 10 | %br/ |
|
11 | - Please login to see the problem list. | |
|
12 | - %br/ | |
|
13 | - %br/ | |
|
14 | 11 | |
|
15 | - - if flash[:notice] | |
|
16 | - %hr/ | |
|
17 | - %b= flash[:notice] | |
|
18 |
- % |
|
|
12 | + - if !@hidelogin | |
|
13 | + Please login to see the problem list. | |
|
14 | + %br/ | |
|
15 | + %br/ | |
|
16 | + | |
|
17 | + - if flash[:notice] | |
|
18 | + %hr/ | |
|
19 | + %b= flash[:notice] | |
|
20 | + %hr/ | |
|
19 | 21 | |
|
20 | - %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} | |
|
21 | - - form_tag :controller => 'login', :action => 'login' do | |
|
22 | - %table | |
|
23 | - %tr | |
|
24 | - %td{:align => "right"} Login: | |
|
25 | - %td= text_field_tag 'login' | |
|
26 | - %tr | |
|
27 | - %td{:align => "right"} Password: | |
|
28 | - %td= password_field_tag | |
|
29 | - = submit_tag 'Login' | |
|
30 | - | |
|
22 | + %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} | |
|
23 | + - form_tag :controller => 'login', :action => 'login' do | |
|
24 | + %table | |
|
25 | + %tr | |
|
26 | + %td{:align => "right"} Login: | |
|
27 | + %td= text_field_tag 'login' | |
|
28 | + %tr | |
|
29 | + %td{:align => "right"} Password: | |
|
30 | + %td= password_field_tag | |
|
31 | + = submit_tag 'Login' | |
|
31 | 32 | %br/ |
|
32 | 33 | |
|
33 | 34 | - if Configuration['system.online_registration'] |
@@ -83,6 +83,7 | |||
|
83 | 83 | User.should_receive(:find_by_login). |
|
84 | 84 | with(login). |
|
85 | 85 | and_return(@john) |
|
86 | + User.should_not_receive(:find_by_email) | |
|
86 | 87 | @john.should_receive(:valid?).and_return(true) |
|
87 | 88 | @john.should_receive(:activated=).with(true) |
|
88 | 89 | @john.should_receive(:save).and_return(true) |
You need to be logged in to leave comments.
Login now