mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-23 15:06:15 -06:00
panic handling
This commit is contained in:
parent
13c03a8909
commit
668dbf2b4d
1 changed files with 6 additions and 14 deletions
|
|
@ -186,13 +186,9 @@ func (s *s) HandleTokenRequest(r *http.Request) (map[string]interface{}, gtserro
|
||||||
// from serialization so that clients don't
|
// from serialization so that clients don't
|
||||||
// interpret the token as already expired.
|
// interpret the token as already expired.
|
||||||
if expiresInI, ok := data["expires_in"]; ok {
|
if expiresInI, ok := data["expires_in"]; ok {
|
||||||
expiresIn, ok := expiresInI.(int64)
|
// This will panic if expiresIn is
|
||||||
if !ok {
|
// not an int64, which is what we want.
|
||||||
log.Panicf(ctx, "could not cast expires_in %T as int64", expiresInI)
|
if expiresInI.(int64) <= 0 {
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if expiresIn <= 0 {
|
|
||||||
delete(data, "expires_in")
|
delete(data, "expires_in")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -275,13 +271,9 @@ func (s *s) HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request) gtser
|
||||||
return gtserror.NewErrorUnauthorized(err, HelpfulAdvice)
|
return gtserror.NewErrorUnauthorized(err, HelpfulAdvice)
|
||||||
}
|
}
|
||||||
|
|
||||||
app, ok := client.(*gtsmodel.Application)
|
// This will panic if client is not a
|
||||||
if !ok {
|
// *gtsmodel.Application, which is what we want.
|
||||||
log.Panicf(ctx, "could not cast %T to *gtsmodel.Application", client)
|
req.RedirectURI = client.(*gtsmodel.Application).RedirectURIs[0]
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
req.RedirectURI = app.RedirectURIs[0]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uri, err := s.server.GetRedirectURI(req, s.server.GetAuthorizeData(req.ResponseType, ti))
|
uri, err := s.server.GetRedirectURI(req, s.server.GetAuthorizeData(req.ResponseType, ti))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue