Feature #7075 » openid.patch
| app/controllers/my_controller.rb (working copy) | ||
|---|---|---|
| 174 | 174 |
end |
| 175 | 175 |
render :nothing => true |
| 176 | 176 |
end |
| 177 |
|
|
| 178 |
def openid |
|
| 179 |
if request.post? |
|
| 180 |
if Setting.openid? && using_open_id? && User.current != User.anonymous |
|
| 181 |
url = url_for :action => 'openid' |
|
| 182 |
current_user = User.current |
|
| 183 |
authenticate_with_open_id(params[:openid_url], :return_to => url) do |result, identity_url, registration| |
|
| 184 |
self.logged_user = current_user |
|
| 185 |
if result.successful? |
|
| 186 |
current_user.identity_url = identity_url |
|
| 187 |
current_user.save |
|
| 188 |
redirect_to :action => 'account' |
|
| 189 |
end |
|
| 190 |
end |
|
| 191 |
end |
|
| 192 |
else |
|
| 193 |
render :action => 'openid' |
|
| 194 |
end |
|
| 195 |
end |
|
| 196 | ||
| 177 | 197 |
end |
| app/controllers/account_controller.rb (working copy) | ||
|---|---|---|
| 158 | 158 | |
| 159 | 159 |
|
| 160 | 160 |
def open_id_authenticate(openid_url) |
| 161 |
authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url) do |result, identity_url, registration| |
|
| 161 |
authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email, 'http://axschema.org/contact/email', 'http://axschema.org/namePerson/first', 'http://axschema.org/namePerson/last'], :return_to => signin_url) do |result, identity_url, registration|
|
|
| 162 | 162 |
if result.successful? |
| 163 | 163 |
user = User.find_or_initialize_by_identity_url(identity_url) |
| 164 | 164 |
if user.new_record? |
| ... | ... | |
| 166 | 166 |
redirect_to(home_url) && return unless Setting.self_registration? |
| 167 | 167 | |
| 168 | 168 |
# Create on the fly |
| 169 |
user.login = registration['nickname'] unless registration['nickname'].nil? |
|
| 170 |
user.mail = registration['email'] unless registration['email'].nil? |
|
| 169 |
login = registration['nickname'] |
|
| 170 |
login = registration['email'] unless !login.nil? |
|
| 171 |
login = registration['http://axschema.org/contact/email'][0] unless !login.nil? |
|
| 172 | ||
| 173 |
email = registration['email'] |
|
| 174 |
email = registration['http://axschema.org/contact/email'][0] unless !email.nil? |
|
| 175 | ||
| 176 |
name = registration['fullname'] |
|
| 177 | ||
| 178 |
user.login = login |
|
| 179 |
user.mail = email |
|
| 171 | 180 |
user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?
|
| 181 |
user.firstname = registration['http://axschema.org/namePerson/first'][0] unless registration['http://axschema.org/namePerson/first'].nil? |
|
| 182 |
user.lastname = registration['http://axschema.org/namePerson/last'][0] unless registration['http://axschema.org/namePerson/last'].nil? |
|
| 172 | 183 |
user.random_password |
| 173 | 184 |
user.register |
| 174 | 185 | |
| 186 |
logger.info user.inspect |
|
| 175 | 187 |
case Setting.self_registration |
| 176 | 188 |
when '1' |
| 177 | 189 |
register_by_email_activation(user) do |
| app/views/my/account.rhtml (working copy) | ||
|---|---|---|
| 16 | 16 |
<p><%= f.text_field :lastname, :required => true %></p> |
| 17 | 17 |
<p><%= f.text_field :mail, :required => true %></p> |
| 18 | 18 |
<p><%= f.select :language, lang_options_for_select %></p> |
| 19 | ||
| 19 | 20 |
<% if Setting.openid? %> |
| 20 |
<p><%= f.text_field :identity_url %></p> |
|
| 21 |
<p><%= f.text_field :identity_url %> (<%= link_to l(:button_update), {:action => 'openid'}, :method => :post %>)</p>
|
|
| 22 | ||
| 21 | 23 |
<% end %> |
| 22 | 24 | |
| 23 | 25 |
<% @user.custom_field_values.select(&:editable?).each do |value| %> |
| app/views/account/login.rhtml (working copy) | ||
|---|---|---|
| 11 | 11 |
<td align="right"><label for="password"><%=l(:field_password)%>:</label></td> |
| 12 | 12 |
<td align="left"><%= password_field_tag 'password', nil, :tabindex => '2' %></td> |
| 13 | 13 |
</tr> |
| 14 |
<% if Setting.openid? %> |
|
| 15 | 14 |
<tr> |
| 16 |
<td align="right"><label for="openid_url"><%=l(:field_identity_url)%></label></td> |
|
| 17 |
<td align="left"><%= text_field_tag "openid_url", nil, :tabindex => '3' %></td> |
|
| 18 |
</tr> |
|
| 19 |
<% end %> |
|
| 20 |
<tr> |
|
| 21 | 15 |
<td></td> |
| 22 | 16 |
<td align="left"> |
| 23 | 17 |
<% if Setting.autologin? %> |
| ... | ... | |
| 38 | 32 |
</table> |
| 39 | 33 |
<%= javascript_tag "Form.Element.focus('username');" %>
|
| 40 | 34 |
<% end %> |
| 35 | ||
| 36 |
<% if Setting.openid? %> |
|
| 37 |
<%= render :partial => 'account/openid', :locals => { :controller => 'account', :action => 'login' } %>
|
|
| 38 |
<% end %> |
|
| 39 | ||
| 41 | 40 |
</div> |
| 41 | ||
| 42 | 42 |
<%= call_hook :view_account_login_bottom %> |
| config/locales/en.yml (working copy) | ||
|---|---|---|
| 811 | 811 |
label_issues_visibility_all: All issues |
| 812 | 812 |
label_issues_visibility_public: All non private issues |
| 813 | 813 |
label_issues_visibility_own: Issues created by or assigned to the user |
| 814 |
label_openid: OpenID Settings |
|
| 814 | 815 |
|
| 815 | 816 |
button_login: Login |
| 816 | 817 |
button_submit: Submit |
| ... | ... | |
| 932 | 933 |
text_zoom_in: Zoom in |
| 933 | 934 |
text_zoom_out: Zoom out |
| 934 | 935 |
text_warn_on_leaving_unsaved: "The current page contains unsaved text that will be lost if you leave this page." |
| 935 |
|
|
| 936 |
text_openid_legend: Sign-in with OpenID |
|
| 937 |
text_openid_provider: "Please click your account provider:" |
|
| 938 |
text_openid_noscript: "OpenID is service that allows you to log-on to many different websites using a single identity. Find out <a href='http://openid.net/what/'>more about OpenID</a> and <a href='http://openid.net/get/'>how to get an OpenID enabled account</a>." |
|
| 939 |
|
|
| 936 | 940 |
default_role_manager: Manager |
| 937 | 941 |
default_role_developer: Developer |
| 938 | 942 |
default_role_reporter: Reporter |