Skip to content

Commit

Permalink
Fix minor issue with created/expires at time
Browse files Browse the repository at this point in the history
  • Loading branch information
Mobilpadde committed Mar 8, 2023
1 parent 70e57e8 commit 20e5e7f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions token/next.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ func (m *Generator) Next() (code.Code, error) {
return code.Code{}, err
}

return code.NewCode(token, m.amount, m.emojies, m.timing.time, m.timing.time.Add(m.period))
period := uint64(m.timing.time.Unix() / int64(m.period.Seconds()))
periodTime := time.Unix(int64(period)*int64(m.period.Seconds()), 0)

return code.NewCode(token, m.amount, m.emojies, periodTime, periodTime.Add(m.period))
}

func (m *Generator) getToken() (string, error) {
Expand All @@ -30,7 +33,6 @@ func (m *Generator) getToken() (string, error) {

m.timing.last = m.timing.curr
m.timing.time = m.timing.time.Add(since)

period := uint64(m.timing.time.Unix() / int64(m.period.Seconds()))

// https://github.com/pquerna/code/blob/master/hotp/hotp.go#L95-L123
Expand Down

0 comments on commit 20e5e7f

Please sign in to comment.