Project

General

Profile

Feature #7075 » openid.patch

Jason Montojo, 2011-04-19 22:41

View differences:

app/controllers/my_controller.rb (working copy)
end
render :nothing => true
end
def openid
if request.post?
if Setting.openid? && using_open_id? && User.current != User.anonymous
url = url_for :action => 'openid'
current_user = User.current
authenticate_with_open_id(params[:openid_url], :return_to => url) do |result, identity_url, registration|
self.logged_user = current_user
if result.successful?
current_user.identity_url = identity_url
current_user.save
redirect_to :action => 'account'
end
end
end
else
render :action => 'openid'
end
end
end
app/controllers/account_controller.rb (working copy)
def open_id_authenticate(openid_url)
authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url) do |result, identity_url, registration|
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|
if result.successful?
user = User.find_or_initialize_by_identity_url(identity_url)
if user.new_record?
......
redirect_to(home_url) && return unless Setting.self_registration?
# Create on the fly
user.login = registration['nickname'] unless registration['nickname'].nil?
user.mail = registration['email'] unless registration['email'].nil?
login = registration['nickname']
login = registration['email'] unless !login.nil?
login = registration['http://axschema.org/contact/email'][0] unless !login.nil?
email = registration['email']
email = registration['http://axschema.org/contact/email'][0] unless !email.nil?
name = registration['fullname']
user.login = login
user.mail = email
user.firstname, user.lastname = registration['fullname'].split(' ') unless registration['fullname'].nil?
user.firstname = registration['http://axschema.org/namePerson/first'][0] unless registration['http://axschema.org/namePerson/first'].nil?
user.lastname = registration['http://axschema.org/namePerson/last'][0] unless registration['http://axschema.org/namePerson/last'].nil?
user.random_password
user.register
logger.info user.inspect
case Setting.self_registration
when '1'
register_by_email_activation(user) do
app/views/my/account.rhtml (working copy)
<p><%= f.text_field :lastname, :required => true %></p>
<p><%= f.text_field :mail, :required => true %></p>
<p><%= f.select :language, lang_options_for_select %></p>
<% if Setting.openid? %>
<p><%= f.text_field :identity_url %></p>
<p><%= f.text_field :identity_url %> (<%= link_to l(:button_update), {:action => 'openid'}, :method => :post %>)</p>
<% end %>
<% @user.custom_field_values.select(&:editable?).each do |value| %>
app/views/account/login.rhtml (working copy)
<td align="right"><label for="password"><%=l(:field_password)%>:</label></td>
<td align="left"><%= password_field_tag 'password', nil, :tabindex => '2' %></td>
</tr>
<% if Setting.openid? %>
<tr>
<td align="right"><label for="openid_url"><%=l(:field_identity_url)%></label></td>
<td align="left"><%= text_field_tag "openid_url", nil, :tabindex => '3' %></td>
</tr>
<% end %>
<tr>
<td></td>
<td align="left">
<% if Setting.autologin? %>
......
</table>
<%= javascript_tag "Form.Element.focus('username');" %>
<% end %>
<% if Setting.openid? %>
<%= render :partial => 'account/openid', :locals => { :controller => 'account', :action => 'login' } %>
<% end %>
</div>
<%= call_hook :view_account_login_bottom %>
config/locales/en.yml (working copy)
label_issues_visibility_all: All issues
label_issues_visibility_public: All non private issues
label_issues_visibility_own: Issues created by or assigned to the user
label_openid: OpenID Settings
button_login: Login
button_submit: Submit
......
text_zoom_in: Zoom in
text_zoom_out: Zoom out
text_warn_on_leaving_unsaved: "The current page contains unsaved text that will be lost if you leave this page."
text_openid_legend: Sign-in with OpenID
text_openid_provider: "Please click your account provider:"
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>."
default_role_manager: Manager
default_role_developer: Developer
default_role_reporter: Reporter
(2-2/3)