Skip to content

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

Rename EnterpriseTrialToken and method in controller

Inga Mai8380fe5d5999
diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb
index 96850fef502..e203e3bf58f 100644
--- a/app/controllers/enterprises_controller.rb
+++ b/app/controllers/enterprises_controller.rb
@@ -59,19 +59,21 @@ class EnterprisesController < ApplicationController
if token
token.destroy
flash[:notice] = t(:notice_successful_delete)
+ trial_key = Token::EnterpriseTrialKey.find_by(user_id: current_user.id)
+ trial_key.destroy
redirect_to action: :show
else
render_404
end
end
- def create_trial_key
+ def save_trial_key
@trial_key = params[:trial_key]
- Token::EnterpriseTrialToken.create(user_id: current_user.id, value: @trial_key)
+ Token::EnterpriseTrialKey.create(user_id: current_user.id, value: @trial_key)
end
def initialize_gon
- @trial_key = Token::EnterpriseTrialToken.find_by!(user_id: current_user.id)
+ @trial_key = Token::EnterpriseTrialKey.find_by(user_id: current_user.id)
if @trial_key
gon.ee_trial_key = {
value: @trial_key.value
diff --git a/app/models/token/enterprise_trial_token.rb b/app/models/token/enterprise_trial_key.rb
similarity index 97%
rename from app/models/token/enterprise_trial_token.rb
rename to app/models/token/enterprise_trial_key.rb
index 0a06d4c096c..c4602a54e3a 100644
--- a/app/models/token/enterprise_trial_token.rb
+++ b/app/models/token/enterprise_trial_key.rb
@@ -31,7 +31,7 @@
require_dependency 'token/base'
module Token
- class EnterpriseTrialToken < Base
+ class EnterpriseTrialKey < Base
include ExpirableToken
def self.validity_time
diff --git a/config/routes.rb b/config/routes.rb
index f8741dae1f3..41bda7036c5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -341,7 +341,7 @@ OpenProject::Application.routes.draw do
constraints(Enterprise) do
resource :enterprise, only: %i[show create destroy]
scope controller: 'enterprises' do
- post 'enterprise/create_trial_key' => 'enterprises#create_trial_key'
+ post 'enterprise/save_trial_key' => 'enterprises#save_trial_key'
end
end
resources :enumerations
diff --git a/frontend/src/app/components/enterprise/enterprise-trial.service.ts b/frontend/src/app/components/enterprise/enterprise-trial.service.ts
index 6c7032c1325..b62e5bd37bd 100644
--- a/frontend/src/app/components/enterprise/enterprise-trial.service.ts
+++ b/frontend/src/app/components/enterprise/enterprise-trial.service.ts
@@ -81,8 +81,6 @@ export class EnterpriseTrialService {
.then((res:any) => {
// show confirmed status and enable continue btn
this.confirmed = true;
- // delete trial key from gon after mail was confirmed
- (window as any).gon.ee_trial_key = undefined;
// returns token if mail was confirmed
// -> if token is new (token_retrieved: false) save token in backend
@@ -126,7 +124,7 @@ export class EnterpriseTrialService {
let trialKey = resendlink.split('/')[6];
// save requested token
return this.http.post(
- this.pathHelper.api.v3.appBasePath + '/admin/enterprise/create_trial_key',
+ this.pathHelper.api.v3.appBasePath + '/admin/enterprise/save_trial_key',
{ trial_key: trialKey },
{ withCredentials: true }
)