@user.terms_seen = true
if @user.save
- flash[:notice] = t "user.new.terms declined", :url => t("user.new.terms declined url")
+ flash[:notice] = t("user.new.terms declined", :url => t("user.new.terms declined url")).html_safe
end
if params[:referer]
:auth_provider => params[:auth_provider],
:auth_uid => params[:auth_uid])
- flash.now[:notice] = t "user.new.auth association"
+ flash.now[:notice] = render_to_string :partial => "auth_association"
else
check_signup_allowed
end
password_authentication(params[:username], params[:password])
elsif params[:openid_url].present?
session[:remember_me] ||= params[:remember_me_openid]
- redirect_to auth_url("openid", params[:openid_url])
+ redirect_to auth_url("openid", params[:openid_url], params[:referer])
end
end
else
user = User.find_by_display_name(params[:display_name])
- redirect_to root_path if !user || user.active?
+ redirect_to root_path if user.nil? || user.active?
end
end
def confirm_resend
- if user = User.find_by_display_name(params[:display_name])
- Notifier.signup_confirm(user, user.tokens.create).deliver_now
- flash[:notice] = t "user.confirm_resend.success", :email => "your email" # user.email
- else
+ user = User.find_by_display_name(params[:display_name])
+ token = UserToken.find_by_token(session[:token])
+
+ if user.nil? || token.nil? || token.user != user
flash[:error] = t "user.confirm_resend.failure", :name => params[:display_name]
+ else
+ Notifier.signup_confirm(user, user.tokens.create).deliver_now
+ flash[:notice] = t("user.confirm_resend.success", :email => user.email).html_safe
end
redirect_to :action => "login"
when "openid"
email_verified = uid.match(%r{https://www.google.com/accounts/o8/id?(.*)}) ||
uid.match(%r{https://me.yahoo.com/(.*)})
- when "google"
+ when "google", "facebook"
email_verified = true
else
email_verified = false
when "pending" then
unconfirmed_login(user)
when "active", "confirmed" then
- successful_login(user)
+ successful_login(user, env["omniauth.params"]["referer"])
when "suspended" then
failed_login t("user.login.account is suspended", :webmaster => "mailto:webmaster@openstreetmap.org")
else
##
# return the URL to use for authentication
- def auth_url(provider, uid)
- if provider == "openid"
- auth_path(:provider => "openid", :openid_url => openid_expand_url(uid), :origin => request.path)
+ def auth_url(provider, uid, referer = nil)
+ params = { :provider => provider }
+
+ params[:openid_url] = openid_expand_url(uid) if provider == "openid"
+
+ if referer.nil?
+ params[:origin] = request.path
else
- auth_path(:provider => provider, :origin => request.path)
+ params[:origin] = request.path + "?referer=" + CGI.escape(referer)
+ params[:referer] = referer
end
+
+ auth_path(params)
end
##
##
# process a successful login
- def successful_login(user)
+ def successful_login(user, referer = nil)
session[:user] = user.id
session_expires_after 28.days if session[:remember_me]
- target = session[:referer] || url_for(:controller => :site, :action => :index)
+ target = referer || session[:referer] || url_for(:controller => :site, :action => :index)
# The user is logged in, so decide where to send them:
#
def failed_login(message)
flash[:error] = message
- redirect_to :action => "login", :referer => session[:referer]
+ redirect_to :action => "login", :referer => session[:referer]
session.delete(:remember_me)
session.delete(:referer)
##
#
def unconfirmed_login(user)
+ session[:token] = user.tokens.create.token
+
redirect_to :action => "confirm", :display_name => user.display_name
session.delete(:remember_me)