Skip to content

Commit

Permalink
Merge pull request #49 from LyricTian/develop
Browse files Browse the repository at this point in the history
update refreshing token config
  • Loading branch information
LyricTian authored May 8, 2017
2 parents 4c69c58 + d85b5f3 commit 38556ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manage/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ type Config struct {

// RefreshingConfig refreshing token config
type RefreshingConfig struct {
// access token expiration time
AccessTokenExp time.Duration
// refresh token expiration time
RefreshTokenExp time.Duration
// whether to generate the refreshing token
IsGenerateRefresh bool
// whether to reset the refreshing create time
Expand Down
8 changes: 8 additions & 0 deletions manage/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,14 @@ func (m *Manager) RefreshAccessToken(tgr *oauth2.TokenGenerateRequest) (accessTo
ti.SetAccess(tv)
ti.SetAccessCreateAt(td.CreateAt)

if v := rcfg.AccessTokenExp; v > 0 {
ti.SetAccessExpiresIn(v)
}

if v := rcfg.RefreshTokenExp; v > 0 {
ti.SetRefreshExpiresIn(v)
}

if rcfg.IsResetRefreshTime {
ti.SetRefreshCreateAt(td.CreateAt)
}
Expand Down

0 comments on commit 38556ca

Please sign in to comment.