Ver Fonte

fix creating access token returning wrong result

jerryliao há 2 anos atrás
pai
commit
0e853bc6f5
1 ficheiros alterados com 1 adições e 3 exclusões
  1. 1 3
      internal/db/access_tokens.go

+ 1 - 3
internal/db/access_tokens.go

@@ -107,15 +107,13 @@ func (db *accessTokens) Create(ctx context.Context, userID int64, name string) (
 	accessToken := &AccessToken{
 		UserID: userID,
 		Name:   name,
-		Sha1:   sha256[:40], // To pass the column unique constraint, keep the length of SHA1.
+		Sha1:   token,
 		SHA256: sha256,
 	}
 	if err = db.WithContext(ctx).Create(accessToken).Error; err != nil {
 		return nil, err
 	}
 
-	// Set back the raw access token value, for the sake of the caller.
-	accessToken.Sha1 = token
 	return accessToken, nil
 }