OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
move methods into private scope unless actions
ulferts0d78c3a2799b
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rbindex ebb0b295951..12e7243cb5d 100644--- a/app/controllers/account_controller.rb+++ b/app/controllers/account_controller.rb@@ -146,20 +146,6 @@ class AccountController < ApplicationControllerendend- def allow_registration?- allow = Setting::SelfRegistration.enabled? && !OpenProject::Configuration.disable_password_login?-- invited = session[:invitation_token].present?- get = request.get? && allow- post = (request.post? || request.patch?) && (session[:auth_source_registration] || allow)-- invited || get || post- end-- def allow_lost_password_recovery?- Setting.lost_password? && !OpenProject::Configuration.disable_password_login?- end-# Token based account activationdef activatetoken = ::Token::Invitation.find_by_plaintext_value(params[:token])@@ -177,6 +163,36 @@ class AccountController < ApplicationControllerendend+ # Process a password change form, used when the user is forced+ # to change the password.+ # When making changes here, also check MyController.change_password+ def change_password+ # Retrieve user_id from session+ @user = User.find(params[:password_change_user_id])++ change_password_flow(user: @user, params:, show_user_name: true) do+ password_authentication(@user.login, params[:new_password])+ end+ rescue ActiveRecord::RecordNotFound+ Rails.logger.error "Failed to find user for change_password request: #{flash[:_password_change_user_id]}"+ render_404+ end++ def auth_source_sso_failed+ failure = session.delete :auth_source_sso_failure+ user = auth_source_sso_failure_user(failure)++ if user.try(:new_record?)+ return onthefly_creation_failed user, login: user.login, ldap_auth_source_id: user.ldap_auth_source_id+ end++ show_sso_error_for(user, failure)++ render action: "login", back_url: failure[:back_url]+ end++ private+def handle_expired_token(token)send_activation_email! token.user@@ -255,50 +271,32 @@ class AccountController < ApplicationControllerredirect_to signin_path(username: user.login)end- # Process a password change form, used when the user is forced- # to change the password.- # When making changes here, also check MyController.change_password- def change_password- # Retrieve user_id from session- @user = User.find(params[:password_change_user_id])-- change_password_flow(user: @user, params:, show_user_name: true) do- password_authentication(@user.login, params[:new_password])- end- rescue ActiveRecord::RecordNotFound- Rails.logger.error "Failed to find user for change_password request: #{flash[:_password_change_user_id]}"- render_404- end-- def auth_source_sso_failed- failure = session.delete :auth_source_sso_failure- login = failure[:login]- user = find_user_from_auth_source(login) || build_user_from_auth_source(login)-- if user.try(:new_record?)- return onthefly_creation_failed user, login: user.login, ldap_auth_source_id: user.ldap_auth_source_id- end-- show_sso_error_for user+ def allow_registration?+ allow = Setting::SelfRegistration.enabled? && !OpenProject::Configuration.disable_password_login?- flash.now[:error] = I18n.t(:error_auth_source_sso_failed, value: failure[:login]) +- ": " + String(flash.now[:error])+ invited = session[:invitation_token].present?+ get = request.get? && allow+ post = (request.post? || request.patch?) && (session[:auth_source_registration] || allow)- render action: "login", back_url: failure[:back_url]+ invited || get || postend- private+ def allow_lost_password_recovery?+ Setting.lost_password? && !OpenProject::Configuration.disable_password_login?+ enddef check_auth_source_sso_failureredirect_to home_url unless session[:auth_source_sso_failure].present?end- def show_sso_error_for(user)+ def show_sso_error_for(user, failure)if user.nil?flash_and_log_invalid_credentialselsif not user.active?account_inactive user, flash_now: trueend++ flash.now[:error] = "#{I18n.t(:error_auth_source_sso_failed, value: failure[:login])}: #{String(flash.now[:error])}"enddef registration_through_invitation!@@ -536,4 +534,10 @@ class AccountController < ApplicationControllerdef check_internal_login_enabledrender_404 unless omniauth_direct_login?end++ def auth_source_sso_failure_user(failure)+ login = failure[:login]++ find_user_from_auth_source(login) || build_user_from_auth_source(login)+ endend