1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 12:54:53 -05:00

Validate response before further processing

This commit is contained in:
erik 2023-12-20 12:22:03 +01:00 committed by Michael Jerger
parent 2f4b1a5cd4
commit 3363b3bf0c

View file

@ -188,10 +188,19 @@ func createUserFromAP(ctx *context.APIContext, personId forgefed.PersonId) (*use
if err != nil {
return &user_model.User{}, err
}
response, err := client.Get(personId.AsUri())
if err != nil {
return &user_model.User{}, err
}
// validate response; ToDo: Should we widen the restrictions here?
if response.StatusCode != 200 {
err = fmt.Errorf("got non 200 status code for id: %v", personId.Id)
return &user_model.User{}, err
}
log.Info("RepositoryInbox: got status: %v", response.Status)
defer response.Body.Close()
body, err := io.ReadAll(response.Body)
if err != nil {