parent
ae419fa494
commit
76a85a4ce9
64 changed files with 250 additions and 242 deletions
|
@ -169,7 +169,7 @@ func repoAssignment() func(ctx *context.APIContext) {
|
|||
repo, err := repo_model.GetRepositoryByName(ctx, owner.ID, repoName)
|
||||
if err != nil {
|
||||
if repo_model.IsErrRepoNotExist(err) {
|
||||
redirectRepoID, err := repo_model.LookupRedirect(owner.ID, repoName)
|
||||
redirectRepoID, err := repo_model.LookupRedirect(ctx, owner.ID, repoName)
|
||||
if err == nil {
|
||||
context.RedirectToRepo(ctx.Base, redirectRepoID)
|
||||
} else if repo_model.IsErrRedirectNotExist(err) {
|
||||
|
|
|
@ -58,7 +58,7 @@ func ListHooks(ctx *context.APIContext) {
|
|||
RepoID: ctx.Repo.Repository.ID,
|
||||
}
|
||||
|
||||
count, err := webhook.CountWebhooksByOpts(opts)
|
||||
count, err := webhook.CountWebhooksByOpts(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
|
@ -301,7 +301,7 @@ func DeleteHook(ctx *context.APIContext) {
|
|||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
if err := webhook.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
|
||||
if err := webhook.DeleteWebhookByRepoID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
|
||||
if webhook.IsErrWebhookNotExist(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
|
|
|
@ -177,7 +177,7 @@ func prepareIssueStopwatch(ctx *context.APIContext, shouldExist bool) (*issues_m
|
|||
return nil, errors.New("Unable to write to PRs")
|
||||
}
|
||||
|
||||
if !ctx.Repo.CanUseTimetracker(issue, ctx.Doer) {
|
||||
if !ctx.Repo.CanUseTimetracker(ctx, issue, ctx.Doer) {
|
||||
ctx.Status(http.StatusForbidden)
|
||||
return nil, errors.New("Cannot use time tracker")
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ func GetStopwatches(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
apiSWs, err := convert.ToStopWatches(sws)
|
||||
apiSWs, err := convert.ToStopWatches(ctx, sws)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "APIFormat", err)
|
||||
return
|
||||
|
|
|
@ -191,7 +191,7 @@ func AddTime(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
if !ctx.Repo.CanUseTimetracker(issue, ctx.Doer) {
|
||||
if !ctx.Repo.CanUseTimetracker(ctx, issue, ctx.Doer) {
|
||||
if !ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
|
||||
ctx.Error(http.StatusBadRequest, "", "time tracking disabled")
|
||||
return
|
||||
|
@ -274,7 +274,7 @@ func ResetIssueTime(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
if !ctx.Repo.CanUseTimetracker(issue, ctx.Doer) {
|
||||
if !ctx.Repo.CanUseTimetracker(ctx, issue, ctx.Doer) {
|
||||
if !ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
|
||||
ctx.JSON(http.StatusBadRequest, struct{ Message string }{Message: "time tracking disabled"})
|
||||
return
|
||||
|
@ -347,7 +347,7 @@ func DeleteTime(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
if !ctx.Repo.CanUseTimetracker(issue, ctx.Doer) {
|
||||
if !ctx.Repo.CanUseTimetracker(ctx, issue, ctx.Doer) {
|
||||
if !ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
|
||||
ctx.JSON(http.StatusBadRequest, struct{ Message string }{Message: "time tracking disabled"})
|
||||
return
|
||||
|
|
|
@ -96,7 +96,7 @@ func ListDeployKeys(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
count, err := asymkey_model.CountDeployKeys(opts)
|
||||
count, err := asymkey_model.CountDeployKeys(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
|
@ -238,7 +238,7 @@ func CreateDeployKey(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
key, err := asymkey_model.AddDeployKey(ctx.Repo.Repository.ID, form.Title, content, form.ReadOnly)
|
||||
key, err := asymkey_model.AddDeployKey(ctx, ctx.Repo.Repository.ID, form.Title, content, form.ReadOnly)
|
||||
if err != nil {
|
||||
HandleAddKeyError(ctx, err)
|
||||
return
|
||||
|
|
|
@ -811,7 +811,7 @@ func MergePullRequest(ctx *context.APIContext) {
|
|||
|
||||
// handle manually-merged mark
|
||||
if manuallyMerged {
|
||||
if err := pull_service.MergedManually(pr, ctx.Doer, ctx.Repo.GitRepo, form.MergeCommitID); err != nil {
|
||||
if err := pull_service.MergedManually(ctx, pr, ctx.Doer, ctx.Repo.GitRepo, form.MergeCommitID); err != nil {
|
||||
if models.IsErrInvalidMergeStyle(err) {
|
||||
ctx.Error(http.StatusMethodNotAllowed, "Invalid merge style", fmt.Errorf("%s is not allowed an allowed merge style for this repository", repo_model.MergeStyle(form.Do)))
|
||||
return
|
||||
|
|
|
@ -236,7 +236,7 @@ func CreateOauth2Application(ctx *context.APIContext) {
|
|||
ctx.Error(http.StatusBadRequest, "", "error creating oauth2 application")
|
||||
return
|
||||
}
|
||||
secret, err := app.GenerateClientSecret()
|
||||
secret, err := app.GenerateClientSecret(ctx)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusBadRequest, "", "error creating application secret")
|
||||
return
|
||||
|
@ -266,7 +266,7 @@ func ListOauth2Applications(ctx *context.APIContext) {
|
|||
// "200":
|
||||
// "$ref": "#/responses/OAuth2ApplicationList"
|
||||
|
||||
apps, total, err := auth_model.ListOAuth2Applications(ctx.Doer.ID, utils.GetListOptions(ctx))
|
||||
apps, total, err := auth_model.ListOAuth2Applications(ctx, ctx.Doer.ID, utils.GetListOptions(ctx))
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "ListOAuth2Applications", err)
|
||||
return
|
||||
|
@ -302,7 +302,7 @@ func DeleteOauth2Application(ctx *context.APIContext) {
|
|||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
appID := ctx.ParamsInt64(":id")
|
||||
if err := auth_model.DeleteOAuth2Application(appID, ctx.Doer.ID); err != nil {
|
||||
if err := auth_model.DeleteOAuth2Application(ctx, appID, ctx.Doer.ID); err != nil {
|
||||
if auth_model.IsErrOAuthApplicationNotFound(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
|
@ -377,7 +377,7 @@ func UpdateOauth2Application(ctx *context.APIContext) {
|
|||
|
||||
data := web.GetForm(ctx).(*api.CreateOAuth2ApplicationOptions)
|
||||
|
||||
app, err := auth_model.UpdateOAuth2Application(auth_model.UpdateOAuth2ApplicationOptions{
|
||||
app, err := auth_model.UpdateOAuth2Application(ctx, auth_model.UpdateOAuth2ApplicationOptions{
|
||||
Name: data.Name,
|
||||
UserID: ctx.Doer.ID,
|
||||
ID: appID,
|
||||
|
@ -392,7 +392,7 @@ func UpdateOauth2Application(ctx *context.APIContext) {
|
|||
}
|
||||
return
|
||||
}
|
||||
app.ClientSecret, err = app.GenerateClientSecret()
|
||||
app.ClientSecret, err = app.GenerateClientSecret(ctx)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusBadRequest, "", "error updating application secret")
|
||||
return
|
||||
|
|
|
@ -185,9 +185,9 @@ func VerifyUserGPGKey(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
_, err := asymkey_model.VerifyGPGKey(ctx.Doer.ID, form.KeyID, token, form.Signature)
|
||||
_, err := asymkey_model.VerifyGPGKey(ctx, ctx.Doer.ID, form.KeyID, token, form.Signature)
|
||||
if err != nil && asymkey_model.IsErrGPGInvalidTokenSignature(err) {
|
||||
_, err = asymkey_model.VerifyGPGKey(ctx.Doer.ID, form.KeyID, lastToken, form.Signature)
|
||||
_, err = asymkey_model.VerifyGPGKey(ctx, ctx.Doer.ID, form.KeyID, lastToken, form.Signature)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -26,7 +26,7 @@ func ListOwnerHooks(ctx *context.APIContext, owner *user_model.User) {
|
|||
OwnerID: owner.ID,
|
||||
}
|
||||
|
||||
count, err := webhook.CountWebhooksByOpts(opts)
|
||||
count, err := webhook.CountWebhooksByOpts(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
|
@ -53,7 +53,7 @@ func ListOwnerHooks(ctx *context.APIContext, owner *user_model.User) {
|
|||
|
||||
// GetOwnerHook gets an user or organization webhook. Errors are written to ctx.
|
||||
func GetOwnerHook(ctx *context.APIContext, ownerID, hookID int64) (*webhook.Webhook, error) {
|
||||
w, err := webhook.GetWebhookByOwnerID(ownerID, hookID)
|
||||
w, err := webhook.GetWebhookByOwnerID(ctx, ownerID, hookID)
|
||||
if err != nil {
|
||||
if webhook.IsErrWebhookNotExist(err) {
|
||||
ctx.NotFound()
|
||||
|
@ -68,7 +68,7 @@ func GetOwnerHook(ctx *context.APIContext, ownerID, hookID int64) (*webhook.Webh
|
|||
// GetRepoHook get a repo's webhook. If there is an error, write to `ctx`
|
||||
// accordingly and return the error
|
||||
func GetRepoHook(ctx *context.APIContext, repoID, hookID int64) (*webhook.Webhook, error) {
|
||||
w, err := webhook.GetWebhookByRepoID(repoID, hookID)
|
||||
w, err := webhook.GetWebhookByRepoID(ctx, repoID, hookID)
|
||||
if err != nil {
|
||||
if webhook.IsErrWebhookNotExist(err) {
|
||||
ctx.NotFound()
|
||||
|
@ -392,7 +392,7 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *webhook.Webh
|
|||
w.IsActive = *form.Active
|
||||
}
|
||||
|
||||
if err := webhook.UpdateWebhook(w); err != nil {
|
||||
if err := webhook.UpdateWebhook(ctx, w); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "UpdateWebhook", err)
|
||||
return false
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *webhook.Webh
|
|||
|
||||
// DeleteOwnerHook deletes the hook owned by the owner.
|
||||
func DeleteOwnerHook(ctx *context.APIContext, owner *user_model.User, hookID int64) {
|
||||
if err := webhook.DeleteWebhookByOwnerID(owner.ID, hookID); err != nil {
|
||||
if err := webhook.DeleteWebhookByOwnerID(ctx, owner.ID, hookID); err != nil {
|
||||
if webhook.IsErrWebhookNotExist(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
|
|
|
@ -136,7 +136,7 @@ func InitWebInstalled(ctx context.Context) {
|
|||
mustInitCtx(ctx, common.InitDBEngine)
|
||||
log.Info("ORM engine initialization successful!")
|
||||
mustInit(system.Init)
|
||||
mustInit(oauth2.Init)
|
||||
mustInitCtx(ctx, oauth2.Init)
|
||||
|
||||
mustInitCtx(ctx, models.Init)
|
||||
mustInitCtx(ctx, authmodel.Init)
|
||||
|
|
|
@ -35,7 +35,7 @@ func UpdatePublicKeyInRepo(ctx *context.PrivateContext) {
|
|||
return
|
||||
}
|
||||
deployKey.UpdatedUnix = timeutil.TimeStampNow()
|
||||
if err = asymkey_model.UpdateDeployKeyCols(deployKey, "updated_unix"); err != nil {
|
||||
if err = asymkey_model.UpdateDeployKeyCols(ctx, deployKey, "updated_unix"); err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, private.Response{
|
||||
Err: err.Error(),
|
||||
})
|
||||
|
|
|
@ -448,7 +448,7 @@ func DeleteAuthSource(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if err = auth_service.DeleteSource(source); err != nil {
|
||||
if err = auth_service.DeleteSource(ctx, source); err != nil {
|
||||
if auth.IsErrSourceInUse(err) {
|
||||
ctx.Flash.Error(ctx.Tr("admin.auths.still_in_used"))
|
||||
} else {
|
||||
|
|
|
@ -160,7 +160,7 @@ func SignIn(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
orderedOAuth2Names, oauth2Providers, err := oauth2.GetActiveOAuth2Providers()
|
||||
orderedOAuth2Names, oauth2Providers, err := oauth2.GetActiveOAuth2Providers(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
return
|
||||
|
@ -184,7 +184,7 @@ func SignIn(ctx *context.Context) {
|
|||
func SignInPost(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("sign_in")
|
||||
|
||||
orderedOAuth2Names, oauth2Providers, err := oauth2.GetActiveOAuth2Providers()
|
||||
orderedOAuth2Names, oauth2Providers, err := oauth2.GetActiveOAuth2Providers(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
return
|
||||
|
@ -408,7 +408,7 @@ func SignUp(ctx *context.Context) {
|
|||
|
||||
ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/sign_up"
|
||||
|
||||
orderedOAuth2Names, oauth2Providers, err := oauth2.GetActiveOAuth2Providers()
|
||||
orderedOAuth2Names, oauth2Providers, err := oauth2.GetActiveOAuth2Providers(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignUp", err)
|
||||
return
|
||||
|
@ -438,7 +438,7 @@ func SignUpPost(ctx *context.Context) {
|
|||
|
||||
ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/sign_up"
|
||||
|
||||
orderedOAuth2Names, oauth2Providers, err := oauth2.GetActiveOAuth2Providers()
|
||||
orderedOAuth2Names, oauth2Providers, err := oauth2.GetActiveOAuth2Providers(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignUp", err)
|
||||
return
|
||||
|
@ -604,7 +604,7 @@ func handleUserCreated(ctx *context.Context, u *user_model.User, gothUser *goth.
|
|||
|
||||
// update external user information
|
||||
if gothUser != nil {
|
||||
if err := externalaccount.UpdateExternalUser(u, *gothUser); err != nil {
|
||||
if err := externalaccount.UpdateExternalUser(ctx, u, *gothUser); err != nil {
|
||||
if !errors.Is(err, util.ErrNotExist) {
|
||||
log.Error("UpdateExternalUser failed: %v", err)
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ func LinkAccountPostRegister(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
authSource, err := auth.GetActiveOAuth2SourceByName(gothUser.Provider)
|
||||
authSource, err := auth.GetActiveOAuth2SourceByName(ctx, gothUser.Provider)
|
||||
if err != nil {
|
||||
ctx.ServerError("CreateUser", err)
|
||||
return
|
||||
|
|
|
@ -847,7 +847,7 @@ func handleAuthorizeError(ctx *context.Context, authErr AuthorizeError, redirect
|
|||
func SignInOAuth(ctx *context.Context) {
|
||||
provider := ctx.Params(":provider")
|
||||
|
||||
authSource, err := auth.GetActiveOAuth2SourceByName(provider)
|
||||
authSource, err := auth.GetActiveOAuth2SourceByName(ctx, provider)
|
||||
if err != nil {
|
||||
ctx.ServerError("SignIn", err)
|
||||
return
|
||||
|
@ -868,7 +868,7 @@ func SignInOAuth(ctx *context.Context) {
|
|||
|
||||
if err = authSource.Cfg.(*oauth2.Source).Callout(ctx.Req, ctx.Resp); err != nil {
|
||||
if strings.Contains(err.Error(), "no provider for ") {
|
||||
if err = oauth2.ResetOAuth2(); err != nil {
|
||||
if err = oauth2.ResetOAuth2(ctx); err != nil {
|
||||
ctx.ServerError("SignIn", err)
|
||||
return
|
||||
}
|
||||
|
@ -898,7 +898,7 @@ func SignInOAuthCallback(ctx *context.Context) {
|
|||
}
|
||||
|
||||
// first look if the provider is still active
|
||||
authSource, err := auth.GetActiveOAuth2SourceByName(provider)
|
||||
authSource, err := auth.GetActiveOAuth2SourceByName(ctx, provider)
|
||||
if err != nil {
|
||||
ctx.ServerError("SignIn", err)
|
||||
return
|
||||
|
@ -1151,7 +1151,7 @@ func handleOAuth2SignIn(ctx *context.Context, source *auth.Source, u *user_model
|
|||
}
|
||||
|
||||
// update external user information
|
||||
if err := externalaccount.UpdateExternalUser(u, gothUser); err != nil {
|
||||
if err := externalaccount.UpdateExternalUser(ctx, u, gothUser); err != nil {
|
||||
if !errors.Is(err, util.ErrNotExist) {
|
||||
log.Error("UpdateExternalUser failed: %v", err)
|
||||
}
|
||||
|
@ -1274,7 +1274,7 @@ func oAuth2UserLoginCallback(ctx *context.Context, authSource *auth.Source, requ
|
|||
ExternalID: gothUser.UserID,
|
||||
LoginSourceID: authSource.ID,
|
||||
}
|
||||
hasUser, err = user_model.GetExternalLogin(externalLoginUser)
|
||||
hasUser, err = user_model.GetExternalLogin(request.Context(), externalLoginUser)
|
||||
if err != nil {
|
||||
return nil, goth.User{}, err
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ func Webhooks(ctx *context.Context) {
|
|||
|
||||
// DeleteWebhook response for delete webhook
|
||||
func DeleteWebhook(ctx *context.Context) {
|
||||
if err := webhook.DeleteWebhookByOwnerID(ctx.Org.Organization.ID, ctx.FormInt64("id")); err != nil {
|
||||
if err := webhook.DeleteWebhookByOwnerID(ctx, ctx.Org.Organization.ID, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteWebhookByOwnerID: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
|
||||
|
|
|
@ -108,7 +108,7 @@ func httpBase(ctx *context.Context) *serviceHandler {
|
|||
repo, err := repo_model.GetRepositoryByName(ctx, owner.ID, reponame)
|
||||
if err != nil {
|
||||
if repo_model.IsErrRepoNotExist(err) {
|
||||
if redirectRepoID, err := repo_model.LookupRedirect(owner.ID, reponame); err == nil {
|
||||
if redirectRepoID, err := repo_model.LookupRedirect(ctx, owner.ID, reponame); err == nil {
|
||||
context.RedirectToRepo(ctx.Base, redirectRepoID)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -830,7 +830,7 @@ func RetrieveRepoMetas(ctx *context.Context, repo *repo_model.Repository, isPull
|
|||
}
|
||||
|
||||
// Contains true if the user can create issue dependencies
|
||||
ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.Doer, isPull)
|
||||
ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx, ctx.Doer, isPull)
|
||||
|
||||
return labels
|
||||
}
|
||||
|
@ -1548,7 +1548,7 @@ func ViewIssue(ctx *context.Context) {
|
|||
ctx.Data["OtherStopwatchURL"] = swIssue.Link()
|
||||
}
|
||||
}
|
||||
ctx.Data["CanUseTimetracker"] = ctx.Repo.CanUseTimetracker(issue, ctx.Doer)
|
||||
ctx.Data["CanUseTimetracker"] = ctx.Repo.CanUseTimetracker(ctx, issue, ctx.Doer)
|
||||
} else {
|
||||
ctx.Data["CanUseTimetracker"] = false
|
||||
}
|
||||
|
@ -1559,7 +1559,7 @@ func ViewIssue(ctx *context.Context) {
|
|||
}
|
||||
|
||||
// Check if the user can use the dependencies
|
||||
ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx.Doer, issue.IsPull)
|
||||
ctx.Data["CanCreateIssueDependencies"] = ctx.Repo.CanCreateIssueDependencies(ctx, ctx.Doer, issue.IsPull)
|
||||
|
||||
// check if dependencies can be created across repositories
|
||||
ctx.Data["AllowCrossRepositoryDependencies"] = setting.Service.AllowCrossRepositoryDependencies
|
||||
|
|
|
@ -22,7 +22,7 @@ func AddDependency(ctx *context.Context) {
|
|||
}
|
||||
|
||||
// Check if the Repo is allowed to have dependencies
|
||||
if !ctx.Repo.CanCreateIssueDependencies(ctx.Doer, issue.IsPull) {
|
||||
if !ctx.Repo.CanCreateIssueDependencies(ctx, ctx.Doer, issue.IsPull) {
|
||||
ctx.Error(http.StatusForbidden, "CanCreateIssueDependencies")
|
||||
return
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ func RemoveDependency(ctx *context.Context) {
|
|||
}
|
||||
|
||||
// Check if the Repo is allowed to have dependencies
|
||||
if !ctx.Repo.CanCreateIssueDependencies(ctx.Doer, issue.IsPull) {
|
||||
if !ctx.Repo.CanCreateIssueDependencies(ctx, ctx.Doer, issue.IsPull) {
|
||||
ctx.Error(http.StatusForbidden, "CanCreateIssueDependencies")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func IssueStopwatch(c *context.Context) {
|
|||
showSuccessMessage = true
|
||||
}
|
||||
|
||||
if !c.Repo.CanUseTimetracker(issue, c.Doer) {
|
||||
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
|
||||
c.NotFound("CanUseTimetracker", nil)
|
||||
return
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func CancelStopwatch(c *context.Context) {
|
|||
if c.Written() {
|
||||
return
|
||||
}
|
||||
if !c.Repo.CanUseTimetracker(issue, c.Doer) {
|
||||
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
|
||||
c.NotFound("CanUseTimetracker", nil)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ func AddTimeManually(c *context.Context) {
|
|||
if c.Written() {
|
||||
return
|
||||
}
|
||||
if !c.Repo.CanUseTimetracker(issue, c.Doer) {
|
||||
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
|
||||
c.NotFound("CanUseTimetracker", nil)
|
||||
return
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ func DeleteTime(c *context.Context) {
|
|||
if c.Written() {
|
||||
return
|
||||
}
|
||||
if !c.Repo.CanUseTimetracker(issue, c.Doer) {
|
||||
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
|
||||
c.NotFound("CanUseTimetracker", nil)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1170,7 +1170,7 @@ func MergePullRequest(ctx *context.Context) {
|
|||
|
||||
// handle manually-merged mark
|
||||
if manuallyMerged {
|
||||
if err := pull_service.MergedManually(pr, ctx.Doer, ctx.Repo.GitRepo, form.MergeCommitID); err != nil {
|
||||
if err := pull_service.MergedManually(ctx, pr, ctx.Doer, ctx.Repo.GitRepo, form.MergeCommitID); err != nil {
|
||||
switch {
|
||||
|
||||
case models.IsErrInvalidMergeStyle(err):
|
||||
|
|
|
@ -70,7 +70,7 @@ func DeployKeysPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
key, err := asymkey_model.AddDeployKey(ctx.Repo.Repository.ID, form.Title, content, !form.IsWritable)
|
||||
key, err := asymkey_model.AddDeployKey(ctx, ctx.Repo.Repository.ID, form.Title, content, !form.IsWritable)
|
||||
if err != nil {
|
||||
ctx.Data["HasError"] = true
|
||||
switch {
|
||||
|
|
|
@ -300,7 +300,7 @@ func editWebhook(ctx *context.Context, params webhookParams) {
|
|||
if err := w.UpdateEvent(); err != nil {
|
||||
ctx.ServerError("UpdateEvent", err)
|
||||
return
|
||||
} else if err := webhook.UpdateWebhook(w); err != nil {
|
||||
} else if err := webhook.UpdateWebhook(ctx, w); err != nil {
|
||||
ctx.ServerError("UpdateWebhook", err)
|
||||
return
|
||||
}
|
||||
|
@ -589,9 +589,9 @@ func checkWebhook(ctx *context.Context) (*ownerRepoCtx, *webhook.Webhook) {
|
|||
|
||||
var w *webhook.Webhook
|
||||
if orCtx.RepoID > 0 {
|
||||
w, err = webhook.GetWebhookByRepoID(orCtx.RepoID, ctx.ParamsInt64(":id"))
|
||||
w, err = webhook.GetWebhookByRepoID(ctx, orCtx.RepoID, ctx.ParamsInt64(":id"))
|
||||
} else if orCtx.OwnerID > 0 {
|
||||
w, err = webhook.GetWebhookByOwnerID(orCtx.OwnerID, ctx.ParamsInt64(":id"))
|
||||
w, err = webhook.GetWebhookByOwnerID(ctx, orCtx.OwnerID, ctx.ParamsInt64(":id"))
|
||||
} else if orCtx.IsAdmin {
|
||||
w, err = webhook.GetSystemOrDefaultWebhook(ctx, ctx.ParamsInt64(":id"))
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ func checkWebhook(ctx *context.Context) (*ownerRepoCtx, *webhook.Webhook) {
|
|||
ctx.Data["PackagistHook"] = webhook_service.GetPackagistHook(w)
|
||||
}
|
||||
|
||||
ctx.Data["History"], err = w.History(1)
|
||||
ctx.Data["History"], err = w.History(ctx, 1)
|
||||
if err != nil {
|
||||
ctx.ServerError("History", err)
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ func WebHooksEdit(ctx *context.Context) {
|
|||
// TestWebhook test if web hook is work fine
|
||||
func TestWebhook(ctx *context.Context) {
|
||||
hookID := ctx.ParamsInt64(":id")
|
||||
w, err := webhook.GetWebhookByRepoID(ctx.Repo.Repository.ID, hookID)
|
||||
w, err := webhook.GetWebhookByRepoID(ctx, ctx.Repo.Repository.ID, hookID)
|
||||
if err != nil {
|
||||
ctx.Flash.Error("GetWebhookByRepoID: " + err.Error())
|
||||
ctx.Status(http.StatusInternalServerError)
|
||||
|
@ -724,7 +724,7 @@ func ReplayWebhook(ctx *context.Context) {
|
|||
|
||||
// DeleteWebhook delete a webhook
|
||||
func DeleteWebhook(ctx *context.Context) {
|
||||
if err := webhook.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
if err := webhook.DeleteWebhookByRepoID(ctx, ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteWebhookByRepoID: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
|
||||
|
|
|
@ -47,7 +47,7 @@ func AvatarByUserName(ctx *context.Context) {
|
|||
// AvatarByEmailHash redirects the browser to the email avatar link
|
||||
func AvatarByEmailHash(ctx *context.Context) {
|
||||
hash := ctx.Params(":hash")
|
||||
email, err := avatars.GetEmailForHash(hash)
|
||||
email, err := avatars.GetEmailForHash(ctx, hash)
|
||||
if err != nil {
|
||||
ctx.ServerError("invalid avatar hash: "+hash, err)
|
||||
return
|
||||
|
|
|
@ -784,7 +784,7 @@ func ShowGPGKeys(ctx *context.Context) {
|
|||
entities := make([]*openpgp.Entity, 0)
|
||||
failedEntitiesID := make([]string, 0)
|
||||
for _, k := range keys {
|
||||
e, err := asymkey_model.GPGKeyToEntity(k)
|
||||
e, err := asymkey_model.GPGKeyToEntity(ctx, k)
|
||||
if err != nil {
|
||||
if asymkey_model.IsErrGPGKeyImportNotExist(err) {
|
||||
failedEntitiesID = append(failedEntitiesID, k.KeyID)
|
||||
|
|
|
@ -61,7 +61,7 @@ func KeysPost(ctx *context.Context) {
|
|||
ctx.Redirect(setting.AppSubURL + "/user/settings/keys")
|
||||
return
|
||||
}
|
||||
if _, err = asymkey_model.AddPrincipalKey(ctx.Doer.ID, content, 0); err != nil {
|
||||
if _, err = asymkey_model.AddPrincipalKey(ctx, ctx.Doer.ID, content, 0); err != nil {
|
||||
ctx.Data["HasPrincipalError"] = true
|
||||
switch {
|
||||
case asymkey_model.IsErrKeyAlreadyExist(err), asymkey_model.IsErrKeyNameAlreadyUsed(err):
|
||||
|
@ -131,9 +131,9 @@ func KeysPost(ctx *context.Context) {
|
|||
token := asymkey_model.VerificationToken(ctx.Doer, 1)
|
||||
lastToken := asymkey_model.VerificationToken(ctx.Doer, 0)
|
||||
|
||||
keyID, err := asymkey_model.VerifyGPGKey(ctx.Doer.ID, form.KeyID, token, form.Signature)
|
||||
keyID, err := asymkey_model.VerifyGPGKey(ctx, ctx.Doer.ID, form.KeyID, token, form.Signature)
|
||||
if err != nil && asymkey_model.IsErrGPGInvalidTokenSignature(err) {
|
||||
keyID, err = asymkey_model.VerifyGPGKey(ctx.Doer.ID, form.KeyID, lastToken, form.Signature)
|
||||
keyID, err = asymkey_model.VerifyGPGKey(ctx, ctx.Doer.ID, form.KeyID, lastToken, form.Signature)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.Data["HasGPGVerifyError"] = true
|
||||
|
@ -195,9 +195,9 @@ func KeysPost(ctx *context.Context) {
|
|||
token := asymkey_model.VerificationToken(ctx.Doer, 1)
|
||||
lastToken := asymkey_model.VerificationToken(ctx.Doer, 0)
|
||||
|
||||
fingerprint, err := asymkey_model.VerifySSHKey(ctx.Doer.ID, form.Fingerprint, token, form.Signature)
|
||||
fingerprint, err := asymkey_model.VerifySSHKey(ctx, ctx.Doer.ID, form.Fingerprint, token, form.Signature)
|
||||
if err != nil && asymkey_model.IsErrSSHInvalidTokenSignature(err) {
|
||||
fingerprint, err = asymkey_model.VerifySSHKey(ctx.Doer.ID, form.Fingerprint, lastToken, form.Signature)
|
||||
fingerprint, err = asymkey_model.VerifySSHKey(ctx, ctx.Doer.ID, form.Fingerprint, lastToken, form.Signature)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.Data["HasSSHVerifyError"] = true
|
||||
|
@ -285,7 +285,7 @@ func loadKeysData(ctx *context.Context) {
|
|||
// generate a new aes cipher using the csrfToken
|
||||
ctx.Data["TokenToSign"] = tokenToSign
|
||||
|
||||
principals, err := asymkey_model.ListPrincipalKeys(ctx.Doer.ID, db.ListOptions{})
|
||||
principals, err := asymkey_model.ListPrincipalKeys(ctx, ctx.Doer.ID, db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("ListPrincipalKeys", err)
|
||||
return
|
||||
|
|
|
@ -62,7 +62,7 @@ func (oa *OAuth2CommonHandlers) AddApp(ctx *context.Context) {
|
|||
// render the edit page with secret
|
||||
ctx.Flash.Success(ctx.Tr("settings.create_oauth2_application_success"), true)
|
||||
ctx.Data["App"] = app
|
||||
ctx.Data["ClientSecret"], err = app.GenerateClientSecret()
|
||||
ctx.Data["ClientSecret"], err = app.GenerateClientSecret(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("GenerateClientSecret", err)
|
||||
return
|
||||
|
@ -101,7 +101,7 @@ func (oa *OAuth2CommonHandlers) EditSave(ctx *context.Context) {
|
|||
|
||||
// TODO validate redirect URI
|
||||
var err error
|
||||
if ctx.Data["App"], err = auth.UpdateOAuth2Application(auth.UpdateOAuth2ApplicationOptions{
|
||||
if ctx.Data["App"], err = auth.UpdateOAuth2Application(ctx, auth.UpdateOAuth2ApplicationOptions{
|
||||
ID: ctx.ParamsInt64("id"),
|
||||
Name: form.Name,
|
||||
RedirectURIs: util.SplitTrimSpace(form.RedirectURIs, "\n"),
|
||||
|
@ -131,7 +131,7 @@ func (oa *OAuth2CommonHandlers) RegenerateSecret(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
ctx.Data["App"] = app
|
||||
ctx.Data["ClientSecret"], err = app.GenerateClientSecret()
|
||||
ctx.Data["ClientSecret"], err = app.GenerateClientSecret(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("GenerateClientSecret", err)
|
||||
return
|
||||
|
@ -142,7 +142,7 @@ func (oa *OAuth2CommonHandlers) RegenerateSecret(ctx *context.Context) {
|
|||
|
||||
// DeleteApp deletes the given oauth2 application
|
||||
func (oa *OAuth2CommonHandlers) DeleteApp(ctx *context.Context) {
|
||||
if err := auth.DeleteOAuth2Application(ctx.ParamsInt64("id"), oa.OwnerID); err != nil {
|
||||
if err := auth.DeleteOAuth2Application(ctx, ctx.ParamsInt64("id"), oa.OwnerID); err != nil {
|
||||
ctx.ServerError("DeleteOAuth2Application", err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ func DeleteAccountLink(ctx *context.Context) {
|
|||
if id <= 0 {
|
||||
ctx.Flash.Error("Account link id is not given")
|
||||
} else {
|
||||
if _, err := user_model.RemoveAccountLink(ctx.Doer, id); err != nil {
|
||||
if _, err := user_model.RemoveAccountLink(ctx, ctx.Doer, id); err != nil {
|
||||
ctx.Flash.Error("RemoveAccountLink: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("settings.remove_account_link_success"))
|
||||
|
@ -73,7 +73,7 @@ func loadSecurityData(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Tokens"] = tokens
|
||||
|
||||
accountLinks, err := user_model.ListAccountLinks(ctx.Doer)
|
||||
accountLinks, err := user_model.ListAccountLinks(ctx, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("ListAccountLinks", err)
|
||||
return
|
||||
|
@ -105,7 +105,7 @@ func loadSecurityData(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["AccountLinks"] = sources
|
||||
|
||||
orderedOAuth2Names, oauth2Providers, err := oauth2.GetActiveOAuth2Providers()
|
||||
orderedOAuth2Names, oauth2Providers, err := oauth2.GetActiveOAuth2Providers(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetActiveOAuth2Providers", err)
|
||||
return
|
||||
|
|
|
@ -36,7 +36,7 @@ func Webhooks(ctx *context.Context) {
|
|||
|
||||
// DeleteWebhook response for delete webhook
|
||||
func DeleteWebhook(ctx *context.Context) {
|
||||
if err := webhook.DeleteWebhookByOwnerID(ctx.Doer.ID, ctx.FormInt64("id")); err != nil {
|
||||
if err := webhook.DeleteWebhookByOwnerID(ctx, ctx.Doer.ID, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteWebhookByOwnerID: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
|
||||
|
|
|
@ -29,7 +29,7 @@ func GetStopwatches(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
apiSWs, err := convert.ToStopWatches(sws)
|
||||
apiSWs, err := convert.ToStopWatches(ctx, sws)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue