feat(auth): Use user info for iFlow auth identifier

This commit is contained in:
hkfires
2025-10-05 20:11:30 +08:00
parent eac8b1a27f
commit 8ca041cfcf
3 changed files with 48 additions and 45 deletions

View File

@@ -1013,13 +1013,17 @@ func (h *Handler) RequestIFlowToken(c *gin.Context) {
}
tokenStorage := authSvc.CreateTokenStorage(tokenData)
tokenStorage.Email = fmt.Sprintf("iflow-%d", time.Now().UnixMilli())
identifier := strings.TrimSpace(tokenStorage.Email)
if identifier == "" {
identifier = fmt.Sprintf("iflow-%d", time.Now().UnixMilli())
tokenStorage.Email = identifier
}
record := &coreauth.Auth{
ID: fmt.Sprintf("iflow-%s.json", tokenStorage.Email),
ID: fmt.Sprintf("iflow-%s.json", identifier),
Provider: "iflow",
FileName: fmt.Sprintf("iflow-%s.json", tokenStorage.Email),
FileName: fmt.Sprintf("iflow-%s.json", identifier),
Storage: tokenStorage,
Metadata: map[string]any{"email": tokenStorage.Email, "api_key": tokenStorage.APIKey},
Metadata: map[string]any{"email": identifier, "api_key": tokenStorage.APIKey},
Attributes: map[string]string{"api_key": tokenStorage.APIKey},
}