|
|
|
@ -16,6 +16,7 @@ import (
|
|
|
|
"github.com/cloudreve/Cloudreve/v4/pkg/serializer"
|
|
|
|
"github.com/cloudreve/Cloudreve/v4/pkg/serializer"
|
|
|
|
"github.com/cloudreve/Cloudreve/v4/pkg/util"
|
|
|
|
"github.com/cloudreve/Cloudreve/v4/pkg/util"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
|
|
|
"github.com/samber/lo"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
type (
|
|
|
|
@ -90,6 +91,11 @@ func (s *GrantService) Get(c *gin.Context) (*GrantResponse, error) {
|
|
|
|
return nil, serializer.NewError(serializer.CodeParamErr, "Invalid scope requested", nil)
|
|
|
|
return nil, serializer.NewError(serializer.CodeParamErr, "Invalid scope requested", nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Must have openid scope
|
|
|
|
|
|
|
|
if !lo.Contains(requestedScopes, types.ScopeOpenID) {
|
|
|
|
|
|
|
|
return nil, serializer.NewError(serializer.CodeParamErr, "openid scope required", nil)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 3. Create/update grant
|
|
|
|
// 3. Create/update grant
|
|
|
|
if err := oAuthClient.UpsertGrant(c, user.ID, app.ID, requestedScopes); err != nil {
|
|
|
|
if err := oAuthClient.UpsertGrant(c, user.ID, app.ID, requestedScopes); err != nil {
|
|
|
|
return nil, serializer.NewError(serializer.CodeDBError, "Failed to create grant", err)
|
|
|
|
return nil, serializer.NewError(serializer.CodeDBError, "Failed to create grant", err)
|
|
|
|
|