mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-07 16:20:28 +08:00
feat: fix bug that token endpoint doesn't return 400/401 when type is object.TokenError (#3808)
This commit is contained in:
@ -224,10 +224,11 @@ func (c *ApiController) GetOAuthToken() {
|
|||||||
if deviceCode != "" {
|
if deviceCode != "" {
|
||||||
deviceAuthCache, ok := object.DeviceAuthMap.Load(deviceCode)
|
deviceAuthCache, ok := object.DeviceAuthMap.Load(deviceCode)
|
||||||
if !ok {
|
if !ok {
|
||||||
c.Data["json"] = object.TokenError{
|
c.Data["json"] = &object.TokenError{
|
||||||
Error: "expired_token",
|
Error: "expired_token",
|
||||||
ErrorDescription: "token is expired",
|
ErrorDescription: "token is expired",
|
||||||
}
|
}
|
||||||
|
c.SetTokenErrorHttpStatus()
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
c.SetTokenErrorHttpStatus()
|
c.SetTokenErrorHttpStatus()
|
||||||
return
|
return
|
||||||
@ -235,20 +236,22 @@ func (c *ApiController) GetOAuthToken() {
|
|||||||
|
|
||||||
deviceAuthCacheCast := deviceAuthCache.(object.DeviceAuthCache)
|
deviceAuthCacheCast := deviceAuthCache.(object.DeviceAuthCache)
|
||||||
if !deviceAuthCacheCast.UserSignIn {
|
if !deviceAuthCacheCast.UserSignIn {
|
||||||
c.Data["json"] = object.TokenError{
|
c.Data["json"] = &object.TokenError{
|
||||||
Error: "authorization_pending",
|
Error: "authorization_pending",
|
||||||
ErrorDescription: "authorization pending",
|
ErrorDescription: "authorization pending",
|
||||||
}
|
}
|
||||||
|
c.SetTokenErrorHttpStatus()
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
c.SetTokenErrorHttpStatus()
|
c.SetTokenErrorHttpStatus()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if deviceAuthCacheCast.RequestAt.Add(time.Second * 120).Before(time.Now()) {
|
if deviceAuthCacheCast.RequestAt.Add(time.Second * 120).Before(time.Now()) {
|
||||||
c.Data["json"] = object.TokenError{
|
c.Data["json"] = &object.TokenError{
|
||||||
Error: "expired_token",
|
Error: "expired_token",
|
||||||
ErrorDescription: "token is expired",
|
ErrorDescription: "token is expired",
|
||||||
}
|
}
|
||||||
|
c.SetTokenErrorHttpStatus()
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
c.SetTokenErrorHttpStatus()
|
c.SetTokenErrorHttpStatus()
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user