]> git.openstreetmap.org Git - rails.git/commitdiff
Merge branch 'master' into openid
authorTom Hughes <tom@compton.nu>
Mon, 6 Sep 2010 11:49:10 +0000 (12:49 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 6 Sep 2010 11:49:10 +0000 (12:49 +0100)
Conflicts:
app/controllers/user_controller.rb
app/views/user/terms.html.erb
config/locales/en.yml

1  2 
app/controllers/user_controller.rb
app/views/user/account.html.erb
app/views/user/terms.html.erb
config/locales/en.yml
config/locales/is.yml

index aae059252242d292e083dfc3066f752cdfa0d181,b9cca0cf6798cb39f6dd828a5d104443b81be655..cc4ae4cd82e455479c5697bffa30862e39bbddbe
@@@ -25,47 -24,20 +24,50 @@@ class UserController < ApplicationContr
  
      if request.xhr?
        render :update do |page|
-         page.replace_html "contributorTerms", :partial => "terms"
+         page.replace_html "contributorTerms", :partial => "terms", :locals => { :has_decline => params[:has_decline] }
+       end
++    elsif using_open_id?
++      # The redirect from the OpenID provider reenters here
++      # again and we need to pass the parameters through to
++      # the open_id_authentication function
++      @user = session.delete(:new_user)
++
++      openid_verify(nil, @user) do |user|
 +      end
-     elsif params[:user]
++
++      if @user.openid_url.nil? or @user.invalid?
++        render :action => 'new'
++      else
++        render :action => 'terms'
++      end
+     else
 +      session[:referer] = params[:referer]
 +
-       @user = User.new(params[:user])
+       @title = t 'user.terms.title'
+       @user = User.new(params[:user]) if params[:user]
  
-       if @user.valid?
-         if params[:user][:openid_url].nil? or
-             params[:user][:openid_url].empty?
-           # No OpenID so just move on to the terms
-           render :action => 'terms'
-         else
 +      if params[:user][:openid_url] and @user.pass_crypt.empty?
 +        # We are creating an account with OpenID and no password
 +        # was specified so create a random one
 +        @user.pass_crypt = ActiveSupport::SecureRandom.base64(16) 
 +        @user.pass_crypt_confirmation = @user.pass_crypt 
 +      end
 +
+       if @user
+         if @user.invalid?
++          # Something is wrong, so rerender the form
+           render :action => :new
+         elsif @user.terms_agreed?
++          # Already agreed to terms, so just show settings
+           redirect_to :action => :account, :display_name => @user.display_name
++        elsif params[:user][:openid_url]
 +          # Verify OpenID before moving on
 +          session[:new_user] = @user
 +          openid_verify(params[:user][:openid_url], @user)
          end
        else
-         # Something is wrong, so rerender the form
-         render :action => 'new'
-       end
-     elsif using_open_id?
-       # The redirect from the OpenID provider reenters here
-       # again and we need to pass the parameters through to
-       # the open_id_authentication function
-       @user = session.delete(:new_user)
-       openid_verify(nil, @user) do |user|
-       end
-       if @user.openid_url.nil? or @user.invalid?
-         render :action => 'new'
-       else
-         render :action => 'terms'
++        # Not logged in, so redirect to the login page
+         redirect_to :action => :login, :referer => request.request_uri
        end
      end
    end
    end
  
    def login
 -    @title = t 'user.login.title'
 -
 -    if params[:user]
 -      email_or_display_name = params[:user][:email]
 -      pass = params[:user][:password]
 -      user = User.authenticate(:username => email_or_display_name, :password => pass)
 +    if params[:username] or using_open_id?
 +      session[:remember_me] ||= params[:remember_me]
 +      session[:referer] ||= params[:referer]
  
 -      if user
 -        session[:user] = user.id
 -        session_expires_after 1.month if params[:remember_me]
 -
 -        # The user is logged in, if the referer param exists, redirect
 -        # them to that unless they've also got a block on them, in
 -        # which case redirect them to the block so they can clear it.
 -        if user.blocked_on_view
 -          redirect_to user.blocked_on_view, :referer => params[:referer]
 -        elsif params[:referer]
 -          redirect_to params[:referer]
 -        else
 -          redirect_to :controller => 'site', :action => 'index'
 -        end
 -      elsif User.authenticate(:username => email_or_display_name, :password => pass, :pending => true)
 -        flash.now[:error] = t 'user.login.account not active'
 -      elsif User.authenticate(:username => email_or_display_name, :password => pass, :suspended => true)
 -        webmaster = link_to t('user.login.webmaster'), "mailto:webmaster@openstreetmap.org"
 -        flash.now[:error] = t 'user.login.account suspended', :webmaster => webmaster
 +      if using_open_id?
 +        openid_authentication(params[:openid_url])
        else
 -        flash.now[:error] = t 'user.login.auth failure'
 +        password_authentication(params[:username], params[:password])
        end
      else
-       @title = t 'user.login.title'
+       flash.now[:notice] =  t 'user.login.notice'
      end
    end
  
Simple merge
index ae801bc11b45163b2b5918df487dbefc241ef99b,3b35851991257ee55942dc0f352deafd4b50f5b5..cd8da54daa3b2f2081b562e93659722608345f5a
    </p>
    <p>
      <%= hidden_field_tag('referer', h(params[:referer])) unless params[:referer].nil? %>
-     <%= hidden_field('user', 'email') %>
-     <%= hidden_field('user', 'email_confirmation') %>
-     <%= hidden_field('user', 'display_name') %>
-     <%= hidden_field('user', 'pass_crypt') %>
-     <%= hidden_field('user', 'pass_crypt_confirmation') %>
-     <%= hidden_field('user', 'openid_url') %>
+     <% if params[:user] %>
+       <%= hidden_field('user', 'email') %>
+       <%= hidden_field('user', 'email_confirmation') %>
+       <%= hidden_field('user', 'display_name') %>
+       <%= hidden_field('user', 'pass_crypt') %>
+       <%= hidden_field('user', 'pass_crypt_confirmation') %>
++      <%= hidden_field('user', 'openid_url') %>
+     <% end %>
      <div id="buttons">
-       <%= submit_tag(t('user.terms.decline'), :name => "decline", :id => "decline") %>
+       <% if params[:user] %>
+         <%= submit_tag(t('user.terms.decline'), :name => "decline", :id => "decline") %>
+       <% end %>
        <%= submit_tag(t('user.terms.agree'), :name => "agree", :id => "agree") %>
      </div>
    </p>
index 972e52708bad4275cca6392f59975adae8e0340a,870ea3276025ffa81e7145df6eaa63cbb8bc652d..d027b8a9a6dd481708933e5a21b738c3bc927d8d
        account suspended: Sorry, your account has been suspended due to suspicious activity.<br />Please contact the {{webmaster}} if you wish to discuss this.
        webmaster: webmaster
        auth failure: "Sorry, could not log in with those details."
+       notice: "<a href=\"http://www.osmfoundation.org/wiki/License/We_Are_Changing_The_License\">Find out more about OpenStreetMap's upcoming license change</a> (<a href=\"http://wiki.openstreetmap.org/wiki/ODbL/We_Are_Changing_The_License\">translations</a>) (<a href=\"http://wiki.openstreetmap.org/wiki/Talk:ODbL/Upcoming\">discussion</a>)"
 +      openid missing provider: "Sorry, could not contact your OpenID provider"
 +      openid invalid: "Sorry, your OpenID seems to be malformed"
 +      openid_logo_alt: "Log in with an OpenID"
 +      openid_providers:
 +        openid:
 +          title: Login with an OpenID URL
 +          alt: Login with an OpenID URL
 +        yahoo:
 +          title: Login with a Yahoo! OpenID
 +          alt: Login with a Yahoo! OpenID
 +        google:
 +          title: Login with a Google OpenID
 +          alt: Login with a Google OpenID
 +        myopenid:
 +          title: Login with a myOpenID OpenID
 +          alt: Login with a myOpenID OpenID
 +        wordpress:
 +          title: Login with a Wordpress.com OpenID
 +          alt: Login with a Wordpress.com OpenID
 +        myspace:
 +          title: Login with a MySpace OpenID
 +          alt: Login with a MySpace OpenID
      logout:
        title: "Logout"
        heading: "Logout from OpenStreetMap"
        not displayed publicly: 'Not displayed publicly (see <a href="http://wiki.openstreetmap.org/wiki/Privacy_Policy" title="wiki privacy policy including section on email addresses">privacy policy</a>)'
        display name: "Display Name:"
        display name description: "Your publicly displayed username. You can change this later in the preferences."
 +      openid: "{{logo}} OpenID:"
        password: "Password:"
        confirm password: "Confirm Password:"
 +      use openid: "Alternatively, use {{logo}} OpenID to login"
 +      openid no password: "With OpenID a password is not required, but some extra tools or server may still need one."
 +      openid association: |
 +        <p>Your OpenID is not associated with a OpenStreetMap account yet.</p>
 +        <ul>
 +          <li>If you are new to OpenStreetMap, please create a new account using the form below.</li>
 +          <li>
 +            If you already have an account, you can login to your account
 +            using your username and password and then associate the account
 +            with your OpenID in your user settings.
 +          </li>
 +        </ul> 
        continue: Continue
        flash create success message: "User was successfully created. Check your email for a confirmation note, and you will be mapping in no time :-)<br /><br />Please note that you will not be able to login until you've received and confirmed your email address.<br /><br />If you use an antispam system which sends confirmation requests then please make sure you whitelist webmaster@openstreetmap.org as we are unable to reply to any confirmation requests."
+       terms accepted: "Thanks for accepting the new contributor terms!"
      terms:
+       title: "Contributor terms"
        heading: "Contributor terms"
-       press accept button: "Please read the agreement below and press the agree button to create your account."
+       read and accept: "Please read the agreement below and press the agree button to confirm that you accept the terms of this agreement for your existing and future contributions."
        consider_pd: "In addition to the above agreement, I consider my contributions to be in the Public Domain"
        consider_pd_why: "what's this?"
-       consider_pd_why_url: http://wiki.openstreetmap.org/wiki/Why_would_I_want_my_contributions_to_be_public_domain
+       consider_pd_why_url: http://www.osmfoundation.org/wiki/License/Why_would_I_want_my_contributions_to_be_public_domain
        agree: Agree
        declined: "http://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined"
        decline: "Decline"
Simple merge