Skip to content

Commit 433f3c4

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 6a303e1 + c8c2818 commit 433f3c4

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

app/assets/javascripts/admin/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ define(function(require, exports, module) {
2222
'responseError': function(responseError) {
2323
if (responseError.status >= 500) {
2424
alert('出错啦!刷新一下吧!');
25-
return $q.reject(responseError);
26-
}
27-
else {
28-
return responseError;
2925
}
26+
return $q.reject(responseError);
3027
}
3128
};
3229
}]);

app/controllers/admin/dashboard_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def sync_comment
8686
private
8787
# GA api 请求中发生错误的处理,错误原因如 timeout 等
8888
def ga_request_error(e)
89-
render :text => e.message, :status => e.try(:response).try(:status) || 408 # timeout code default
89+
render :json => {:error => e.message}, :status => e.try(:response).try(:status) || 408 # timeout code default
9090
GaClient.clear_service_account_user
9191

9292
# log error

lib/ga_client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TopPage
3737

3838
# 获取 GA 权限
3939
def self.service_account_user(ga_setting = Ga.find)
40-
if @service_account_user.nil?
40+
if @service_account_user.nil? or @service_account_user.access_token.expired?
4141
client = ::Google::APIClient.new(
4242
:application_name => "SOME_STRING",
4343
:application_version => "SOME_NUMBER"
@@ -49,7 +49,7 @@ def self.service_account_user(ga_setting = Ga.find)
4949
:authorize_url => 'https://accounts.google.com/o/oauth2/auth',
5050
:token_url => 'https://accounts.google.com/o/oauth2/token'
5151
})
52-
token = OAuth2::AccessToken.new(oauth_client, client.authorization.access_token)
52+
token = OAuth2::AccessToken.new(oauth_client, client.authorization.access_token, :expires_in => 5 * 60)
5353
@service_account_user = Legato::User.new(token)
5454
end
5555

0 commit comments

Comments
 (0)