diff options
author | Dennis Tang <dtang@gitlab.com> | 2018-05-26 01:36:56 +0200 |
---|---|---|
committer | Dennis Tang <dtang@gitlab.com> | 2018-05-26 01:36:56 +0200 |
commit | 70c65e827b7974529409e5f9af5c1d094c08ed19 (patch) | |
tree | a4d885806116e72717453ff4134f7792fbe37307 /app/controllers/projects/clusters_controller.rb | |
parent | 2532dc740f93efada473296716a3b903427963a4 (diff) | |
download | gitlab-ce-70c65e827b7974529409e5f9af5c1d094c08ed19.tar.gz |
fix case where token may expire
Diffstat (limited to 'app/controllers/projects/clusters_controller.rb')
-rw-r--r-- | app/controllers/projects/clusters_controller.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index c44949f2125..74e1a78360d 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -171,8 +171,7 @@ class Projects::ClustersController < Projects::ApplicationController end def new_cluster - if GoogleApi::CloudPlatform::Client.new(token_in_session, nil) - .validate_token(expires_at_in_session) + if valid_gcp_token @new_cluster = ::Clusters::Cluster.new.tap do |cluster| cluster.build_provider_gcp end @@ -185,6 +184,11 @@ class Projects::ClustersController < Projects::ApplicationController end end + def valid_gcp_token + @valid_gcp_token = GoogleApi::CloudPlatform::Client.new(token_in_session, nil) + .validate_token(expires_at_in_session) + end + def token_in_session @token_in_session ||= session[GoogleApi::CloudPlatform::Client.session_key_for_token] |