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 | |
parent | 2532dc740f93efada473296716a3b903427963a4 (diff) | |
download | gitlab-ce-70c65e827b7974529409e5f9af5c1d094c08ed19.tar.gz |
fix case where token may expire
-rw-r--r-- | app/controllers/projects/clusters_controller.rb | 8 | ||||
-rw-r--r-- | app/views/projects/clusters/new.html.haml | 2 |
2 files changed, 7 insertions, 3 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] diff --git a/app/views/projects/clusters/new.html.haml b/app/views/projects/clusters/new.html.haml index 718e3564ded..694d34ae4e7 100644 --- a/app/views/projects/clusters/new.html.haml +++ b/app/views/projects/clusters/new.html.haml @@ -20,7 +20,7 @@ .tab-content.gitlab-tab-content .tab-pane{ id: 'create-new-cluster-pane', class: active_when(active_tab == 'new'), role: 'tabpanel' } = render 'projects/clusters/gcp/header' - - if @token_in_session + - if @valid_gcp_token = render 'projects/clusters/gcp/form' - elsif @authorize_url = link_to @authorize_url do |