Skip to content

Commit

Permalink
Add reset to token
Browse files Browse the repository at this point in the history
  • Loading branch information
zachhuff386 committed Jul 27, 2019
1 parent 0d07a0e commit 552ac7e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions service/token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ func (t *Token) Init() (err error) {
return
}

func (t *Token) Reset() (err error) {
logrus.WithFields(logrus.Fields{
"profile": t.Profile,
}).Info("token: Token reset")

t.Valid = false

token, err := utils.RandStrComplex(16)
if err != nil {
return
}

t.Token = token
t.Timestamp = time.Now()

return
}

func (t *Token) Update() (err error) {
if time.Since(t.Timestamp) > time.Duration(t.Ttl)*time.Second {
err = t.Init()
Expand Down

0 comments on commit 552ac7e

Please sign in to comment.