mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-27 20:49:33 +08:00
Handle unauthorized user events gracefully (#15071)
This commit is contained in:
parent
78e8f62706
commit
2f0eb9fd5d
@ -30,6 +30,17 @@ func Events(ctx *context.Context) {
|
||||
ctx.Resp.Header().Set("X-Accel-Buffering", "no")
|
||||
ctx.Resp.WriteHeader(http.StatusOK)
|
||||
|
||||
if !ctx.IsSigned {
|
||||
// Return unauthorized status event
|
||||
event := (&eventsource.Event{
|
||||
Name: "unauthorized",
|
||||
Data: "sorry",
|
||||
})
|
||||
_, _ = event.WriteTo(ctx)
|
||||
ctx.Resp.Flush()
|
||||
return
|
||||
}
|
||||
|
||||
// Listen to connection close and un-register messageChan
|
||||
notify := ctx.Req.Context().Done()
|
||||
ctx.Resp.Flush()
|
||||
|
@ -400,7 +400,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
})
|
||||
}, reqSignOut)
|
||||
|
||||
m.Any("/user/events", reqSignIn, events.Events)
|
||||
m.Any("/user/events", events.Events)
|
||||
|
||||
m.Group("/login/oauth", func() {
|
||||
m.Get("/authorize", bindIgnErr(auth.AuthorizationForm{}), user.AuthorizeOAuth)
|
||||
|
Loading…
Reference in New Issue
Block a user