mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-24 05:56:16 -06:00
enforce scopes
This commit is contained in:
parent
e3857b90bb
commit
21d9edac54
191 changed files with 1473 additions and 648 deletions
|
|
@ -66,9 +66,12 @@ import (
|
|||
// '500':
|
||||
// description: internal server error
|
||||
func (m *Module) NotificationGETHandler(c *gin.Context) {
|
||||
authed, err := apiutil.TokenAuth(c, true, true, true, true)
|
||||
if err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorUnauthorized(err, err.Error()), m.processor.InstanceGetV1)
|
||||
authed, errWithCode := apiutil.TokenAuth(c,
|
||||
true, true, true, true,
|
||||
apiutil.ScopeReadNotifications,
|
||||
)
|
||||
if errWithCode != nil {
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import (
|
|||
//
|
||||
// security:
|
||||
// - OAuth2 Bearer:
|
||||
// - read:notifications
|
||||
// - write:notifications
|
||||
//
|
||||
// responses:
|
||||
// '200':
|
||||
|
|
@ -57,9 +57,12 @@ import (
|
|||
// '500':
|
||||
// description: internal server error
|
||||
func (m *Module) NotificationsClearPOSTHandler(c *gin.Context) {
|
||||
authed, err := apiutil.TokenAuth(c, true, true, true, true)
|
||||
if err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorUnauthorized(err, err.Error()), m.processor.InstanceGetV1)
|
||||
authed, errWithCode := apiutil.TokenAuth(c,
|
||||
true, true, true, true,
|
||||
apiutil.ScopeWriteNotifications,
|
||||
)
|
||||
if errWithCode != nil {
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +71,7 @@ func (m *Module) NotificationsClearPOSTHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
errWithCode := m.processor.Timeline().NotificationsClear(c.Request.Context(), authed)
|
||||
errWithCode = m.processor.Timeline().NotificationsClear(c.Request.Context(), authed)
|
||||
if errWithCode != nil {
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -142,9 +142,12 @@ import (
|
|||
// '500':
|
||||
// description: internal server error
|
||||
func (m *Module) NotificationsGETHandler(c *gin.Context) {
|
||||
authed, err := apiutil.TokenAuth(c, true, true, true, true)
|
||||
if err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorUnauthorized(err, err.Error()), m.processor.InstanceGetV1)
|
||||
authed, errWithCode := apiutil.TokenAuth(c,
|
||||
true, true, true, true,
|
||||
apiutil.ScopeReadNotifications,
|
||||
)
|
||||
if errWithCode != nil {
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue