fix(dashboard): cannot delete user with OAuth grants (close #3354)

This commit is contained in:
Aaron Liu
2026-03-12 16:07:57 +08:00
parent 7a430058b4
commit cb0b5d2a39
2 changed files with 7 additions and 1 deletions

2
assets

Submodule assets updated: a5ade06951...194c0c3f22

View File

@@ -16,6 +16,7 @@ import (
"github.com/cloudreve/Cloudreve/v4/ent"
"github.com/cloudreve/Cloudreve/v4/ent/davaccount"
"github.com/cloudreve/Cloudreve/v4/ent/file"
"github.com/cloudreve/Cloudreve/v4/ent/oauthgrant"
"github.com/cloudreve/Cloudreve/v4/ent/passkey"
"github.com/cloudreve/Cloudreve/v4/ent/schema"
"github.com/cloudreve/Cloudreve/v4/ent/task"
@@ -214,6 +215,11 @@ func (c *userClient) Delete(ctx context.Context, uid int) error {
return fmt.Errorf("failed to delete tasks: %w", err)
}
// OAuth grants
if _, err := c.client.OAuthGrant.Delete().Where(oauthgrant.UserID(uid)).Exec(schema.SkipSoftDelete(ctx)); err != nil {
return fmt.Errorf("failed to delete oauth grants: %w", err)
}
return c.client.User.DeleteOneID(uid).Exec(schema.SkipSoftDelete(ctx))
}