mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 14:53:34 +01:00
Validate response before further processing
This commit is contained in:
parent
2f4b1a5cd4
commit
3363b3bf0c
1 changed files with 9 additions and 0 deletions
|
@ -188,10 +188,19 @@ func createUserFromAP(ctx *context.APIContext, personId forgefed.PersonId) (*use
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &user_model.User{}, err
|
return &user_model.User{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := client.Get(personId.AsUri())
|
response, err := client.Get(personId.AsUri())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &user_model.User{}, err
|
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()
|
defer response.Body.Close()
|
||||||
body, err := io.ReadAll(response.Body)
|
body, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue