OSDN Git Service

fix delete non exist token id successfully
authorlbqds <lbqds@outlook.com>
Fri, 13 Apr 2018 02:51:05 +0000 (10:51 +0800)
committerlbqds <lbqds@outlook.com>
Fri, 13 Apr 2018 02:51:05 +0000 (10:51 +0800)
accesstoken/accesstoken.go

index 6355a18..0e5fa7a 100644 (file)
@@ -136,6 +136,10 @@ func (cs *CredentialStore) Delete(ctx context.Context, id string) error {
                return errors.WithDetailf(ErrBadID, "invalid id %q", id)
        }
 
+       if value := cs.DB.Get([]byte(id)); value == nil {
+               return errors.WithDetailf(ErrNoMatchID, "check id %q", id)
+       }
+
        cs.DB.Delete([]byte(id))
        return nil
 }