enhance(admin): allow regenerating access tokens for bot accounts (#40109)

Bot accounts cannot sign in, so admins manage their access tokens, but
the regenerate button was hidden for them. This adds an admin route to
regenerate a bot's token.

Token regeneration is now also recorded in the audit log.

Fixes: https://github.com/go-gitea/gitea/issues/40074
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
Shivansh Gargandsilverwind authored and GitHub committed 2026-10-31 09:31:56 +00:00
1 parent 08c5fcafd3
commit 365cb2bd5e
6 files changed
+41 -26

No files matched your search

+6
View File
@@ -388,6 +388,12 @@ func DeleteBotToken(ctx *context.Context) {
}
}
func RegenerateBotToken(ctx *context.Context) {
if u := getTargetBot(ctx); u != nil {
user_setting.RegenerateAccessToken(ctx, u)
}
}
func editUserCommon(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("admin.users.edit_account")
ctx.Data["PageIsAdminUsers"] = true