Ensure we dont return already claimed token again (#3420)

This commit is contained in:
Stefan Benten 2019-10-30 22:36:19 +01:00 committed by GitHub
parent bfa6699e2c
commit 44dc2c8c69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,9 +47,12 @@ func (service *Service) GetOrCreate(ctx context.Context, userID string) (_ *Toke
} }
if existingGroup != nil && len(existingGroup) > 0 { if existingGroup != nil && len(existingGroup) > 0 {
authorization := existingGroup[0] for _, authorization := range existingGroup {
if authorization.Claim == nil {
return &authorization.Token, nil return &authorization.Token, nil
} }
}
}
createdGroup, err := service.db.Create(ctx, userID, 1) createdGroup, err := service.db.Create(ctx, userID, 1)
if err != nil { if err != nil {