From: Tom Hughes
Date: Mon, 6 Sep 2010 11:49:10 +0000 (+0100)
Subject: Merge branch 'master' into openid
X-Git-Tag: live~7042
X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/dd7ef37ec023646120358a0a6a7959a392b79f1c
Merge branch 'master' into openid
Conflicts:
app/controllers/user_controller.rb
app/views/user/terms.html.erb
config/locales/en.yml
---
dd7ef37ec023646120358a0a6a7959a392b79f1c
diff --cc app/controllers/user_controller.rb
index aae059252,b9cca0cf6..cc4ae4cd8
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@@ -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 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.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 @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
@@@ -210,17 -191,37 +222,17 @@@
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
diff --cc app/views/user/terms.html.erb
index ae801bc11,3b3585199..cd8da54da
--- a/app/views/user/terms.html.erb
+++ b/app/views/user/terms.html.erb
@@@ -33,14 -33,17 +33,18 @@@
<%= 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 %>
- <%= 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") %>
diff --cc config/locales/en.yml
index 972e52708,870ea3276..d027b8a9a
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@@ -1501,28 -1498,7 +1501,29 @@@ en
account suspended: Sorry, your account has been suspended due to suspicious activity.
Please contact the {{webmaster}} if you wish to discuss this.
webmaster: webmaster
auth failure: "Sorry, could not log in with those details."
+ notice: "Find out more about OpenStreetMap's upcoming license change (translations) (discussion)"
+ 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"
@@@ -1555,29 -1531,18 +1556,31 @@@
not displayed publicly: 'Not displayed publicly (see privacy policy)'
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: |
+ Your OpenID is not associated with a OpenStreetMap account yet.
+
+ - If you are new to OpenStreetMap, please create a new account using the form below.
+ -
+ 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.
+
+
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 :-)
Please note that you will not be able to login until you've received and confirmed your email address.
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"