mirror of
https://github.com/cloudreve/cloudreve.git
synced 2026-06-27 22:35:59 +00:00
fix(dashboard): cannot delete user with OAuth grants (close #3354)
This commit is contained in:
2
assets
2
assets
Submodule assets updated: a5ade06951...194c0c3f22
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user