mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 19:38:23 +00:00 
			
		
		
		
	Refactor legacy code (#35708)
And by the way, remove the legacy TODO, split large functions into small ones, and add more tests
This commit is contained in:
		| @@ -45,7 +45,7 @@ func UpdatePublicKeyInRepo(ctx *context.PrivateContext) { | ||||
| 	ctx.PlainText(http.StatusOK, "success") | ||||
| } | ||||
|  | ||||
| // AuthorizedPublicKeyByContent searches content as prefix (leak e-mail part) | ||||
| // AuthorizedPublicKeyByContent searches content as prefix (without comment part) | ||||
| // and returns public key found. | ||||
| func AuthorizedPublicKeyByContent(ctx *context.PrivateContext) { | ||||
| 	content := ctx.FormString("content") | ||||
| @@ -57,5 +57,14 @@ func AuthorizedPublicKeyByContent(ctx *context.PrivateContext) { | ||||
| 		}) | ||||
| 		return | ||||
| 	} | ||||
| 	ctx.PlainText(http.StatusOK, publicKey.AuthorizedString()) | ||||
|  | ||||
| 	authorizedString, err := asymkey_model.AuthorizedStringForKey(publicKey) | ||||
| 	if err != nil { | ||||
| 		ctx.JSON(http.StatusInternalServerError, private.Response{ | ||||
| 			Err:     err.Error(), | ||||
| 			UserMsg: "invalid public key", | ||||
| 		}) | ||||
| 		return | ||||
| 	} | ||||
| 	ctx.PlainText(http.StatusOK, authorizedString) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user