Skip to content

Commit 560b444

Browse files
committed
Add missing scopes output.
Disallow empty scope.
1 parent f05d9c9 commit 560b444

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

routers/api/v1/user/app.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ func CreateAccessToken(ctx *context.APIContext) {
118118
ctx.Error(http.StatusBadRequest, "AccessTokenScope.Normalize", fmt.Errorf("invalid access token scope provided: %w", err))
119119
return
120120
}
121+
if scope == "" {
122+
ctx.Error(http.StatusBadRequest, "AccessTokenScope", "access token must have a scope")
123+
return
124+
}
121125
t.Scope = scope
122126

123127
if err := auth_model.NewAccessToken(ctx, t); err != nil {
@@ -129,6 +133,7 @@ func CreateAccessToken(ctx *context.APIContext) {
129133
Token: t.Token,
130134
ID: t.ID,
131135
TokenLastEight: t.TokenLastEight,
136+
Scopes: t.Scope.StringSlice(),
132137
})
133138
}
134139

0 commit comments

Comments
 (0)