##// END OF EJS Templates
Added a system setting for allowing OpenID logins and registrations...
Eric Davis -
r2388:8d53e433c55b
parent child
Show More
@@ -46,10 +46,10 class AccountController < ApplicationController
46 self.logged_user = nil
46 self.logged_user = nil
47 else
47 else
48 # Authenticate user
48 # Authenticate user
49 unless using_open_id?
49 if using_open_id? && Setting.openid?
50 password_authentication
51 else
52 open_id_authenticate(params[:openid_url])
50 open_id_authenticate(params[:openid_url])
51 else
52 password_authentication
53 end
53 end
54 end
54 end
55 end
55 end
@@ -10,10 +10,12
10 <td align="right"><label for="password"><%=l(:field_password)%>:</label></td>
10 <td align="right"><label for="password"><%=l(:field_password)%>:</label></td>
11 <td align="left"><%= password_field_tag 'password', nil, :size => 40 %></td>
11 <td align="left"><%= password_field_tag 'password', nil, :size => 40 %></td>
12 </tr>
12 </tr>
13 <% if Setting.openid? %>
13 <tr>
14 <tr>
14 <td align="right"><label for="openid_url"><%=l(:field_identity_url)%></label></td>
15 <td align="right"><label for="openid_url"><%=l(:field_identity_url)%></label></td>
15 <td align="left"><%= text_field_tag "openid_url" %></td>
16 <td align="left"><%= text_field_tag "openid_url" %></td>
16 </tr>
17 </tr>
18 <% end %>
17 <tr>
19 <tr>
18 <td></td>
20 <td></td>
19 <td align="left">
21 <td align="left">
@@ -1,4 +1,4
1 <h2><%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url %></h2>
1 <h2><%=l(:label_register)%><%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></h2>
2
2
3 <% form_tag({:action => 'register'}, :class => "tabular") do %>
3 <% form_tag({:action => 'register'}, :class => "tabular") do %>
4 <%= error_messages_for 'user' %>
4 <%= error_messages_for 'user' %>
@@ -29,8 +29,10
29 <p><label for="user_language"><%=l(:field_language)%></label>
29 <p><label for="user_language"><%=l(:field_language)%></label>
30 <%= select("user", "language", lang_options_for_select) %></p>
30 <%= select("user", "language", lang_options_for_select) %></p>
31
31
32 <% if Setting.openid? %>
32 <p><label for="user_identity_url"><%=l(:field_identity_url)%></label>
33 <p><label for="user_identity_url"><%=l(:field_identity_url)%></label>
33 <%= text_field 'user', 'identity_url' %></p>
34 <%= text_field 'user', 'identity_url' %></p>
35 <% end %>
34
36
35 <% @user.custom_field_values.select {|v| v.editable? || v.required?}.each do |value| %>
37 <% @user.custom_field_values.select {|v| v.editable? || v.required?}.each do |value| %>
36 <p><%= custom_field_tag_with_label :user, value %></p>
38 <p><%= custom_field_tag_with_label :user, value %></p>
@@ -17,6 +17,9
17
17
18 <p><label><%= l(:label_password_lost) %></label>
18 <p><label><%= l(:label_password_lost) %></label>
19 <%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p>
19 <%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p>
20
21 <p><label><%= l(:setting_openid) %></label>
22 <%= check_box_tag 'settings[openid]', 1, Setting.openid? %><%= hidden_field_tag 'settings[openid]', 0 %></p>
20 </div>
23 </div>
21
24
22 <div style="float:right;">
25 <div style="float:right;">
@@ -7,7 +7,9
7 <p><%= f.text_field :lastname, :required => true %></p>
7 <p><%= f.text_field :lastname, :required => true %></p>
8 <p><%= f.text_field :mail, :required => true %></p>
8 <p><%= f.text_field :mail, :required => true %></p>
9 <p><%= f.select :language, lang_options_for_select %></p>
9 <p><%= f.select :language, lang_options_for_select %></p>
10 <% if Setting.openid? %>
10 <p><%= f.text_field :identity_url %></p>
11 <p><%= f.text_field :identity_url %></p>
12 <% end %>
11
13
12 <% @user.custom_field_values.each do |value| %>
14 <% @user.custom_field_values.each do |value| %>
13 <p><%= custom_field_tag_with_label :user, value %></p>
15 <p><%= custom_field_tag_with_label :user, value %></p>
@@ -143,3 +143,5 emails_footer:
143 To change your notification preferences, please click here: http://hostname/my/account
143 To change your notification preferences, please click here: http://hostname/my/account
144 gravatar_enabled:
144 gravatar_enabled:
145 default: 0
145 default: 0
146 openid:
147 default: 0
@@ -229,6 +229,7 setting_sequential_project_identifiers: Generate sequential project identifiers
229 setting_gravatar_enabled: Use Gravatar user icons
229 setting_gravatar_enabled: Use Gravatar user icons
230 setting_diff_max_lines_displayed: Max number of diff lines displayed
230 setting_diff_max_lines_displayed: Max number of diff lines displayed
231 setting_repository_log_display_limit: Maximum number of revisions displayed on file log
231 setting_repository_log_display_limit: Maximum number of revisions displayed on file log
232 setting_openid: Allow OpenID login and registration
232
233
233 permission_edit_project: Edit project
234 permission_edit_project: Edit project
234 permission_select_project_modules: Select project modules
235 permission_select_project_modules: Select project modules
@@ -66,6 +66,7 class AccountControllerTest < Test::Unit::TestCase
66
66
67 def test_login_with_openid_for_existing_user
67 def test_login_with_openid_for_existing_user
68 Setting.self_registration = '3'
68 Setting.self_registration = '3'
69 Setting.openid = '1'
69 existing_user = User.new(:firstname => 'Cool',
70 existing_user = User.new(:firstname => 'Cool',
70 :lastname => 'User',
71 :lastname => 'User',
71 :mail => 'user@somedomain.com',
72 :mail => 'user@somedomain.com',
@@ -79,6 +80,7 class AccountControllerTest < Test::Unit::TestCase
79
80
80 def test_login_with_openid_with_new_user_created
81 def test_login_with_openid_with_new_user_created
81 Setting.self_registration = '3'
82 Setting.self_registration = '3'
83 Setting.openid = '1'
82 post :login, :openid_url => 'http://openid.example.com/good_user'
84 post :login, :openid_url => 'http://openid.example.com/good_user'
83 assert_redirected_to 'my/account'
85 assert_redirected_to 'my/account'
84 user = User.find_by_login('cool_user')
86 user = User.find_by_login('cool_user')
@@ -89,6 +91,7 class AccountControllerTest < Test::Unit::TestCase
89
91
90 def test_login_with_openid_with_new_user_and_self_registration_off
92 def test_login_with_openid_with_new_user_and_self_registration_off
91 Setting.self_registration = '0'
93 Setting.self_registration = '0'
94 Setting.openid = '1'
92 post :login, :openid_url => 'http://openid.example.com/good_user'
95 post :login, :openid_url => 'http://openid.example.com/good_user'
93 assert_redirected_to home_url
96 assert_redirected_to home_url
94 user = User.find_by_login('cool_user')
97 user = User.find_by_login('cool_user')
@@ -97,6 +100,7 class AccountControllerTest < Test::Unit::TestCase
97
100
98 def test_login_with_openid_with_new_user_created_with_email_activation_should_have_a_token
101 def test_login_with_openid_with_new_user_created_with_email_activation_should_have_a_token
99 Setting.self_registration = '1'
102 Setting.self_registration = '1'
103 Setting.openid = '1'
100 post :login, :openid_url => 'http://openid.example.com/good_user'
104 post :login, :openid_url => 'http://openid.example.com/good_user'
101 assert_redirected_to 'login'
105 assert_redirected_to 'login'
102 user = User.find_by_login('cool_user')
106 user = User.find_by_login('cool_user')
@@ -108,6 +112,7 class AccountControllerTest < Test::Unit::TestCase
108
112
109 def test_login_with_openid_with_new_user_created_with_manual_activation
113 def test_login_with_openid_with_new_user_created_with_manual_activation
110 Setting.self_registration = '2'
114 Setting.self_registration = '2'
115 Setting.openid = '1'
111 post :login, :openid_url => 'http://openid.example.com/good_user'
116 post :login, :openid_url => 'http://openid.example.com/good_user'
112 assert_redirected_to 'login'
117 assert_redirected_to 'login'
113 user = User.find_by_login('cool_user')
118 user = User.find_by_login('cool_user')
@@ -117,6 +122,7 class AccountControllerTest < Test::Unit::TestCase
117
122
118 def test_login_with_openid_with_new_user_with_conflict_should_register
123 def test_login_with_openid_with_new_user_with_conflict_should_register
119 Setting.self_registration = '3'
124 Setting.self_registration = '3'
125 Setting.openid = '1'
120 existing_user = User.new(:firstname => 'Cool', :lastname => 'User', :mail => 'user@somedomain.com')
126 existing_user = User.new(:firstname => 'Cool', :lastname => 'User', :mail => 'user@somedomain.com')
121 existing_user.login = 'cool_user'
127 existing_user.login = 'cool_user'
122 assert existing_user.save!
128 assert existing_user.save!
General Comments 0
You need to be logged in to leave comments. Login now