use validation error for expired invite tokens. (#587)

Closes #586
This commit is contained in:
Victor Vrantchan 2016-12-07 11:25:48 -05:00 committed by GitHub
parent 02945f1e3b
commit 6d9ad56e6d
2 changed files with 2 additions and 3 deletions

View File

@ -2,7 +2,6 @@ package service
import (
"encoding/base64"
"errors"
kolide_errors "github.com/kolide/kolide-ose/server/errors"
"github.com/kolide/kolide-ose/server/kolide"
@ -77,7 +76,7 @@ func (svc service) VerifyInvite(ctx context.Context, email, token string) error
expiresAt := invite.CreatedAt.Add(svc.config.App.InviteTokenValidityPeriod)
if svc.clock.Now().After(expiresAt) {
return errors.New("expired invite token")
return newInvalidArgumentError("invite_token", "Invite token has expired.")
}
return nil

View File

@ -165,7 +165,7 @@ func TestCreateUser(t *testing.T) {
NeedsPasswordReset: boolPtr(true),
Admin: boolPtr(false),
InviteToken: &invites["expired"].Token,
wantErr: errors.New("expired invite token"),
wantErr: &invalidArgumentError{{name: "invite_token", reason: "Invite token has expired."}},
},
{
Username: stringPtr("@admin2"),