Skip to content

Commit

Permalink
feat: Allow configured leeway in invitation expiration (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
JigarJoshi authored May 12, 2023
1 parent 31b943f commit 4545a1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/Invitation.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (a *API) VerifyInvitation(w http.ResponseWriter, r *http.Request) error {
defer itr.Close()
var invitation models.Invitation
for itr.Next(&invitation) {
if invitation.Code == params.Code && time.Now().UnixMilli() <= invitation.ExpirationTime && invitation.Status == InvitationStatusPending {
if invitation.Code == params.Code && time.Now().UnixMilli() <= (invitation.ExpirationTime+int64(a.config.InvitationConfig.LeewaySecond)*1000) && invitation.Status == InvitationStatusPending {
// mark invitation as accepted, if not dry
if !params.Dry {
invitation.Status = InvitationStatusAccepted
Expand Down
8 changes: 5 additions & 3 deletions conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ type GlobalConfiguration struct {
}

type InvitationConfiguration struct {
CodeLength int `json:"code_length" default:"30"`
CodePrefix string `json:"code_prefix" default:"ti_"`
HideCode bool `json:"hide_code" default:"false"`
CodeLength int `json:"code_length" default:"30"`
// allows the delay of leeway seconds in expiration of the invitation code
LeewaySecond int `json:"leeway_second" default:"300"`
CodePrefix string `json:"code_prefix" default:"ti_"`
HideCode bool `json:"hide_code" default:"false"`
}

// EmailContentConfiguration holds the configuration for emails, both subjects and template URLs.
Expand Down

0 comments on commit 4545a1d

Please sign in to comment.