File tree 1 file changed +8
-15
lines changed
1 file changed +8
-15
lines changed Original file line number Diff line number Diff line change @@ -81,21 +81,14 @@ func (ts *TokenStore) c(name string) *mgo.Collection {
81
81
82
82
// Create Create and store the new token information
83
83
func (ts * TokenStore ) Create (info oauth2.TokenInfo ) (err error ) {
84
- var expiredAt time.Time
84
+ aexp := info .GetAccessCreateAt ().Add (info .GetAccessExpiresIn ())
85
+ rexp := aexp
85
86
if refresh := info .GetRefresh (); refresh != "" {
86
- expiredAt = info .GetRefreshCreateAt ().Add (info .GetRefreshExpiresIn ())
87
- rinfo , rerr := ts .GetByRefresh (refresh )
88
- if rerr != nil {
89
- err = rerr
90
- return
91
- }
92
- if rinfo != nil {
93
- expiredAt = rinfo .GetRefreshCreateAt ().Add (rinfo .GetRefreshExpiresIn ())
87
+ rexp = info .GetRefreshCreateAt ().Add (info .GetRefreshExpiresIn ())
88
+ if aexp .Second () > rexp .Second () {
89
+ aexp = rexp
94
90
}
95
91
}
96
- if expiredAt .IsZero () {
97
- expiredAt = info .GetAccessCreateAt ().Add (info .GetAccessExpiresIn ())
98
- }
99
92
id := bson .NewObjectId ().Hex ()
100
93
jv , err := json .Marshal (info )
101
94
if err != nil {
@@ -108,15 +101,15 @@ func (ts *TokenStore) Create(info oauth2.TokenInfo) (err error) {
108
101
Assert : txn .DocMissing ,
109
102
Insert : basicData {
110
103
Data : jv ,
111
- ExpiredAt : expiredAt ,
104
+ ExpiredAt : rexp ,
112
105
},
113
106
}, {
114
107
C : ts .tcfg .AccessCName ,
115
108
Id : info .GetAccess (),
116
109
Assert : txn .DocMissing ,
117
110
Insert : tokenData {
118
111
BasicID : id ,
119
- ExpiredAt : info . GetAccessCreateAt (). Add ( info . GetAccessExpiresIn ()) ,
112
+ ExpiredAt : aexp ,
120
113
},
121
114
}}
122
115
if refresh := info .GetRefresh (); refresh != "" {
@@ -126,7 +119,7 @@ func (ts *TokenStore) Create(info oauth2.TokenInfo) (err error) {
126
119
Assert : txn .DocMissing ,
127
120
Insert : tokenData {
128
121
BasicID : id ,
129
- ExpiredAt : expiredAt ,
122
+ ExpiredAt : rexp ,
130
123
},
131
124
})
132
125
}
You can’t perform that action at this time.
0 commit comments