mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Fix the bug: deploy key with write access can not push (#19010)
Use DeployKeyID to replace the IsDeployKey, then CanWriteCode uses the DeployKeyID to check the write permission.
This commit is contained in:
parent
80fd25524e
commit
2b55422cd7
11 changed files with 81 additions and 67 deletions
|
@ -229,8 +229,6 @@ func ServCommand(ctx *context.PrivateContext) {
|
|||
var deployKey *asymkey_model.DeployKey
|
||||
var user *user_model.User
|
||||
if key.Type == asymkey_model.KeyTypeDeploy {
|
||||
results.IsDeployKey = true
|
||||
|
||||
var err error
|
||||
deployKey, err = asymkey_model.GetDeployKeyByRepo(key.ID, repo.ID)
|
||||
if err != nil {
|
||||
|
@ -248,6 +246,7 @@ func ServCommand(ctx *context.PrivateContext) {
|
|||
})
|
||||
return
|
||||
}
|
||||
results.DeployKeyID = deployKey.ID
|
||||
results.KeyName = deployKey.Name
|
||||
|
||||
// FIXME: Deploy keys aren't really the owner of the repo pushing changes
|
||||
|
@ -410,9 +409,9 @@ func ServCommand(ctx *context.PrivateContext) {
|
|||
return
|
||||
}
|
||||
}
|
||||
log.Debug("Serv Results:\nIsWiki: %t\nIsDeployKey: %t\nKeyID: %d\tKeyName: %s\nUserName: %s\nUserID: %d\nOwnerName: %s\nRepoName: %s\nRepoID: %d",
|
||||
log.Debug("Serv Results:\nIsWiki: %t\nDeployKeyID: %d\nKeyID: %d\tKeyName: %s\nUserName: %s\nUserID: %d\nOwnerName: %s\nRepoName: %s\nRepoID: %d",
|
||||
results.IsWiki,
|
||||
results.IsDeployKey,
|
||||
results.DeployKeyID,
|
||||
results.KeyID,
|
||||
results.KeyName,
|
||||
results.UserName,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue