mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-26 05:36:38 +00:00
[bugfix] remove <= 0 expires_in
from oauth token response (#731)
* remove <= 0 expired_in from oauth token response * go fmt
This commit is contained in:
parent
8106b69856
commit
fc81e6443a
|
@ -133,6 +133,23 @@ func (s *s) HandleTokenRequest(r *http.Request) (map[string]interface{}, gtserro
|
||||||
}
|
}
|
||||||
|
|
||||||
data := s.server.GetTokenData(ti)
|
data := s.server.GetTokenData(ti)
|
||||||
|
|
||||||
|
if expiresInI, ok := data["expires_in"]; ok {
|
||||||
|
switch expiresIn := expiresInI.(type) {
|
||||||
|
case int64:
|
||||||
|
// remove this key from the returned map
|
||||||
|
// if the value is 0 or less, so that clients
|
||||||
|
// don't interpret the token as already expired
|
||||||
|
if expiresIn <= 0 {
|
||||||
|
delete(data, "expires_in")
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
err := errors.New("expires_in was set on token response, but was not an int64")
|
||||||
|
return nil, gtserror.NewErrorInternalError(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add this for mastodon api compatibility
|
||||||
data["created_at"] = ti.GetAccessCreateAt().Unix()
|
data["created_at"] = ti.GetAccessCreateAt().Unix()
|
||||||
|
|
||||||
return data, nil
|
return data, nil
|
||||||
|
|
Loading…
Reference in a new issue