Skip to content

Commit 046dec4

Browse files
committed
More user types
1 parent 07be3dd commit 046dec4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

models/user/user.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ func (u *User) IsIndividual() bool {
408408
return u.Type == UserTypeIndividual
409409
}
410410

411+
func (u *User) IsUser() bool {
412+
return u.Type == UserTypeIndividual || u.Type == UserTypeBot
413+
}
414+
411415
// IsBot returns whether or not the user is of type bot
412416
func (u *User) IsBot() bool {
413417
return u.Type == UserTypeBot

routers/api/v1/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ func checkTokenPublicOnly() func(ctx *context.APIContext) {
268268
return
269269
}
270270
case auth_model.ContainsCategory(requiredScopeCategories, auth_model.AccessTokenScopeCategoryUser):
271-
if ctx.ContextUser != nil && !ctx.ContextUser.IsOrganization() && ctx.ContextUser.Visibility != api.VisibleTypePublic {
271+
if ctx.ContextUser != nil && ctx.ContextUser.IsUser() && ctx.ContextUser.Visibility != api.VisibleTypePublic {
272272
ctx.Error(http.StatusForbidden, "reqToken", "token scope is limited to public users")
273273
return
274274
}
275275
case auth_model.ContainsCategory(requiredScopeCategories, auth_model.AccessTokenScopeCategoryActivityPub):
276-
if ctx.ContextUser != nil && !ctx.ContextUser.IsOrganization() && ctx.ContextUser.Visibility != api.VisibleTypePublic {
276+
if ctx.ContextUser != nil && ctx.ContextUser.IsUser() && ctx.ContextUser.Visibility != api.VisibleTypePublic {
277277
ctx.Error(http.StatusForbidden, "reqToken", "token scope is limited to public activitypub")
278278
return
279279
}

0 commit comments

Comments
 (0)