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
Fix pasting of a token and handle simultaneous changes by multiple admins
Inga Maiffdf711d15f0
diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rbindex e203e3bf58f..b3cf4920aa2 100644--- a/app/controllers/enterprises_controller.rb+++ b/app/controllers/enterprises_controller.rb@@ -43,15 +43,26 @@ class EnterprisesController < ApplicationController@current_token = EnterpriseToken.current@token = @current_token || EnterpriseToken.new- if @current_token.blank?+ if !@current_token.present?initialize_gonendenddef create@token = EnterpriseToken.current || EnterpriseToken.new+ saved_encoded_token = @token.encoded_token@token.encoded_token = params[:enterprise_token][:encoded_token]- @token.save+ if @token.save+ flash[:notice] = t(:notice_successful_update)+ redirect_to action: :show+ else+ # restore the old token+ if saved_encoded_token+ @token.encoded_token = saved_encoded_token+ @current_token = @token || EnterpriseToken.new+ end+ render action: :show+ endenddef destroy@@ -59,8 +70,10 @@ class EnterprisesController < ApplicationControllerif tokentoken.destroyflash[:notice] = t(:notice_successful_delete)- trial_key = Token::EnterpriseTrialKey.find_by(user_id: current_user.id)++ trial_key = Token::EnterpriseTrialKey.find_by(user_id: User.system.id)trial_key.destroy+redirect_to action: :showelserender_404@@ -68,12 +81,11 @@ class EnterprisesController < ApplicationControllerenddef save_trial_key- @trial_key = params[:trial_key]- Token::EnterpriseTrialKey.create(user_id: current_user.id, value: @trial_key)+ Token::EnterpriseTrialKey.create(user_id: User.system.id, value: params[:trial_key])enddef initialize_gon- @trial_key = Token::EnterpriseTrialKey.find_by(user_id: current_user.id)+ @trial_key = Token::EnterpriseTrialKey.find_by(user_id: User.system.id)if @trial_keygon.ee_trial_key = {value: @trial_key.valuediff --git a/frontend/src/app/components/enterprise/enterprise-trial.service.ts b/frontend/src/app/components/enterprise/enterprise-trial.service.tsindex 55318b250fb..cce9cd244e8 100644--- a/frontend/src/app/components/enterprise/enterprise-trial.service.ts+++ b/frontend/src/app/components/enterprise/enterprise-trial.service.ts@@ -133,7 +133,7 @@ export class EnterpriseTrialService {).toPromise().catch((error:HttpErrorResponse) => {- this.notificationsService.addError(error.error || I18n.t('js.error.internal'));+ this.notificationsService.addError(error.error.description || I18n.t('js.error.internal'));});}