mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 22:23:50 +03:00
fix: Do not delete global Oauth2 applications
(cherry picked from commit 1d5aee6ef8
)
This commit is contained in:
parent
a3c917b1c1
commit
2d75678303
1 changed files with 2 additions and 0 deletions
|
@ -651,6 +651,7 @@ func CountOrphanedOAuth2Applications(ctx context.Context) (int64, error) {
|
||||||
Table("`oauth2_application`").
|
Table("`oauth2_application`").
|
||||||
Join("LEFT", "`user`", "`oauth2_application`.`uid` = `user`.`id`").
|
Join("LEFT", "`user`", "`oauth2_application`.`uid` = `user`.`id`").
|
||||||
Where(builder.IsNull{"`user`.id"}).
|
Where(builder.IsNull{"`user`.id"}).
|
||||||
|
Where(builder.Neq{"uid": 0}). // exclude instance-wide admin applications
|
||||||
Where(builder.NotIn("`oauth2_application`.`client_id`", BuiltinApplicationsClientIDs())).
|
Where(builder.NotIn("`oauth2_application`.`client_id`", BuiltinApplicationsClientIDs())).
|
||||||
Select("COUNT(`oauth2_application`.`id`)").
|
Select("COUNT(`oauth2_application`.`id`)").
|
||||||
Count()
|
Count()
|
||||||
|
@ -662,6 +663,7 @@ func DeleteOrphanedOAuth2Applications(ctx context.Context) (int64, error) {
|
||||||
From("`oauth2_application`").
|
From("`oauth2_application`").
|
||||||
Join("LEFT", "`user`", "`oauth2_application`.`uid` = `user`.`id`").
|
Join("LEFT", "`user`", "`oauth2_application`.`uid` = `user`.`id`").
|
||||||
Where(builder.IsNull{"`user`.id"}).
|
Where(builder.IsNull{"`user`.id"}).
|
||||||
|
Where(builder.Neq{"uid": 0}). // exclude instance-wide admin applications
|
||||||
Where(builder.NotIn("`oauth2_application`.`client_id`", BuiltinApplicationsClientIDs()))
|
Where(builder.NotIn("`oauth2_application`.`client_id`", BuiltinApplicationsClientIDs()))
|
||||||
|
|
||||||
b := builder.Delete(builder.In("id", subQuery)).From("`oauth2_application`")
|
b := builder.Delete(builder.In("id", subQuery)).From("`oauth2_application`")
|
||||||
|
|
Loading…
Reference in a new issue