AfterFind implements the GORM query hook.
(tx *gorm.DB)
| 39 | |
| 40 | // AfterFind implements the GORM query hook. |
| 41 | func (t *AccessToken) AfterFind(tx *gorm.DB) error { |
| 42 | t.Created = time.Unix(t.CreatedUnix, 0).Local() |
| 43 | if t.UpdatedUnix > 0 { |
| 44 | t.Updated = time.Unix(t.UpdatedUnix, 0).Local() |
| 45 | t.HasUsed = t.Updated.After(t.Created) |
| 46 | t.HasRecentActivity = t.Updated.Add(7 * 24 * time.Hour).After(tx.NowFunc()) |
| 47 | } |
| 48 | return nil |
| 49 | } |
| 50 | |
| 51 | // AccessTokensStore is the storage layer for access tokens. |
| 52 | type AccessTokensStore struct { |