mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	Refactor Actions Token Access (#35688)
* use a single function to do Action Tokens Permission checks * allows easier customization * add basic tests * lfs file locks should work now --------- Signed-off-by: ChristopherHX <christopher.homberger@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -187,13 +187,6 @@ func PostLockHandler(ctx *context.Context) { | ||||
| 			}) | ||||
| 			return | ||||
| 		} | ||||
| 		if git_model.IsErrLFSUnauthorizedAction(err) { | ||||
| 			ctx.Resp.Header().Set("WWW-Authenticate", `Basic realm="gitea-lfs"`) | ||||
| 			ctx.JSON(http.StatusUnauthorized, api.LFSLockError{ | ||||
| 				Message: "You must have push access to create locks : " + err.Error(), | ||||
| 			}) | ||||
| 			return | ||||
| 		} | ||||
| 		log.Error("Unable to CreateLFSLock in repository %-v at %s for user %-v: Error: %v", repository, req.Path, ctx.Doer, err) | ||||
| 		ctx.JSON(http.StatusInternalServerError, api.LFSLockError{ | ||||
| 			Message: "internal server error : Internal Server Error", | ||||
| @@ -317,13 +310,6 @@ func UnLockHandler(ctx *context.Context) { | ||||
|  | ||||
| 	lock, err := git_model.DeleteLFSLockByID(ctx, ctx.PathParamInt64("lid"), repository, ctx.Doer, req.Force) | ||||
| 	if err != nil { | ||||
| 		if git_model.IsErrLFSUnauthorizedAction(err) { | ||||
| 			ctx.Resp.Header().Set("WWW-Authenticate", `Basic realm="gitea-lfs"`) | ||||
| 			ctx.JSON(http.StatusUnauthorized, api.LFSLockError{ | ||||
| 				Message: "You must have push access to delete locks : " + err.Error(), | ||||
| 			}) | ||||
| 			return | ||||
| 		} | ||||
| 		log.Error("Unable to DeleteLFSLockByID[%d] by user %-v with force %t: Error: %v", ctx.PathParamInt64("lid"), ctx.Doer, req.Force, err) | ||||
| 		ctx.JSON(http.StatusInternalServerError, api.LFSLockError{ | ||||
| 			Message: "unable to delete lock : Internal Server Error", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user