X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/36f6d8d85d9549d7652a425600a54cae7be04b4d..34fe4c2ac47e5909ba03ae45132ec3c781129679:/app/controllers/users_controller.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 727d8ee3f..23263ebba 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -28,7 +28,7 @@ class UsersController < ApplicationController if current_user&.terms_agreed? # Already agreed to terms, so just show settings - redirect_to :action => :account, :display_name => current_user.display_name + redirect_to user_account_path(current_user) elsif current_user.nil? && session[:new_user].nil? redirect_to login_path(:referer => request.fullpath) end @@ -44,11 +44,9 @@ class UsersController < ApplicationController flash[:notice] = { :partial => "users/terms_declined_flash" } if current_user.save - if params[:referer] - redirect_to safe_referer(params[:referer]) - else - redirect_to :action => :account, :display_name => current_user.display_name - end + referer = safe_referer(params[:referer]) if params[:referer] + + redirect_to referer || user_account_path(current_user) elsif params[:decline] redirect_to t("users.terms.declined") else @@ -64,11 +62,9 @@ class UsersController < ApplicationController flash[:notice] = t "users.new.terms accepted" if current_user.save end - if params[:referer] - redirect_to safe_referer(params[:referer]) - else - redirect_to :action => :account, :display_name => current_user.display_name - end + referer = safe_referer(params[:referer]) if params[:referer] + + redirect_to referer || user_account_path(current_user) else self.current_user = session.delete(:new_user) @@ -147,7 +143,7 @@ class UsersController < ApplicationController current_user.data_public = true current_user.save flash[:notice] = t "users.go_public.flash success" - redirect_to :action => "account", :display_name => current_user.display_name + redirect_to user_account_path(current_user) end def new @@ -277,15 +273,15 @@ class UsersController < ApplicationController name = auth_info[:info][:name] email = auth_info[:info][:email] - case provider - when "openid" - email_verified = uid.match(%r{https://www.google.com/accounts/o8/id?(.*)}) || + email_verified = case provider + when "openid" + uid.match(%r{https://www.google.com/accounts/o8/id?(.*)}) || uid.match(%r{https://me.yahoo.com/(.*)}) - when "google", "facebook" - email_verified = true - else - email_verified = false - end + when "google", "facebook" + true + else + false + end if settings = session.delete(:new_user_settings) current_user.auth_provider = provider @@ -297,7 +293,7 @@ class UsersController < ApplicationController session[:user_errors] = current_user.errors.as_json - redirect_to :action => "account", :display_name => current_user.display_name + redirect_to user_account_path(current_user) elsif session[:new_user] session[:new_user].auth_provider = provider session[:new_user].auth_uid = uid @@ -335,23 +331,15 @@ class UsersController < ApplicationController ## # omniauth failure callback def auth_failure - flash[:error] = t("users.auth_failure.#{params[:message]}") - redirect_to params[:origin] || login_url - end - - private + flash[:error] = t(params[:message], :scope => "users.auth_failure", :default => t("users.auth_failure.unknown_error")) - ## - # - def unconfirmed_login(user) - session[:token] = user.tokens.create.token + origin = safe_referer(params[:origin]) if params[:origin] - redirect_to :action => "confirm", :display_name => user.display_name - - session.delete(:remember_me) - session.delete(:referer) + redirect_to origin || login_url end + private + ## # update a user's details def update_user(user, params)