fix(ssologin): missing role in SSO auto-registration and minor callback issue (#9305)

* fix(ssologin): return after error response

* fix(ssologin): set default role for SSO user creation
pull/7757/merge
Sakkyoi Cheng 2025-09-04 22:15:39 +08:00 committed by GitHub
parent 23107483a1
commit 930f9f6096
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"encoding/base64"
"errors"
"fmt"
"github.com/alist-org/alist/v3/internal/op"
"net/http"
"net/url"
"path"
@ -154,7 +155,7 @@ func autoRegister(username, userID string, err error) (*model.User, error) {
Password: random.String(16),
Permission: int32(setting.GetInt(conf.SSODefaultPermission, 0)),
BasePath: setting.GetStr(conf.SSODefaultDir),
Role: nil,
Role: model.Roles{op.GetDefaultRoleID()},
Disabled: false,
SsoID: userID,
}
@ -256,6 +257,7 @@ func OIDCLoginCallback(c *gin.Context) {
user, err = autoRegister(userID, userID, err)
if err != nil {
common.ErrorResp(c, err, 400)
return
}
}
token, err := common.GenerateToken(user)