Commit 70c65e82 authored by Dennis Tang's avatar Dennis Tang

fix case where token may expire

parent 2532dc74
...@@ -171,8 +171,7 @@ class Projects::ClustersController < Projects::ApplicationController ...@@ -171,8 +171,7 @@ class Projects::ClustersController < Projects::ApplicationController
end end
def new_cluster def new_cluster
if GoogleApi::CloudPlatform::Client.new(token_in_session, nil) if valid_gcp_token
.validate_token(expires_at_in_session)
@new_cluster = ::Clusters::Cluster.new.tap do |cluster| @new_cluster = ::Clusters::Cluster.new.tap do |cluster|
cluster.build_provider_gcp cluster.build_provider_gcp
end end
...@@ -185,6 +184,11 @@ class Projects::ClustersController < Projects::ApplicationController ...@@ -185,6 +184,11 @@ class Projects::ClustersController < Projects::ApplicationController
end end
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 def token_in_session
@token_in_session ||= @token_in_session ||=
session[GoogleApi::CloudPlatform::Client.session_key_for_token] session[GoogleApi::CloudPlatform::Client.session_key_for_token]
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
.tab-content.gitlab-tab-content .tab-content.gitlab-tab-content
.tab-pane{ id: 'create-new-cluster-pane', class: active_when(active_tab == 'new'), role: 'tabpanel' } .tab-pane{ id: 'create-new-cluster-pane', class: active_when(active_tab == 'new'), role: 'tabpanel' }
= render 'projects/clusters/gcp/header' = render 'projects/clusters/gcp/header'
- if @token_in_session - if @valid_gcp_token
= render 'projects/clusters/gcp/form' = render 'projects/clusters/gcp/form'
- elsif @authorize_url - elsif @authorize_url
= link_to @authorize_url do = link_to @authorize_url do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment