mirror of
https://github.com/AlistGo/alist.git
synced 2025-11-25 19:37:41 +08:00
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
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/alist-org/alist/v3/internal/op"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
@@ -154,7 +155,7 @@ func autoRegister(username, userID string, err error) (*model.User, error) {
|
|||||||
Password: random.String(16),
|
Password: random.String(16),
|
||||||
Permission: int32(setting.GetInt(conf.SSODefaultPermission, 0)),
|
Permission: int32(setting.GetInt(conf.SSODefaultPermission, 0)),
|
||||||
BasePath: setting.GetStr(conf.SSODefaultDir),
|
BasePath: setting.GetStr(conf.SSODefaultDir),
|
||||||
Role: nil,
|
Role: model.Roles{op.GetDefaultRoleID()},
|
||||||
Disabled: false,
|
Disabled: false,
|
||||||
SsoID: userID,
|
SsoID: userID,
|
||||||
}
|
}
|
||||||
@@ -256,6 +257,7 @@ func OIDCLoginCallback(c *gin.Context) {
|
|||||||
user, err = autoRegister(userID, userID, err)
|
user, err = autoRegister(userID, userID, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ErrorResp(c, err, 400)
|
common.ErrorResp(c, err, 400)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
token, err := common.GenerateToken(user)
|
token, err := common.GenerateToken(user)
|
||||||
|
|||||||
Reference in New Issue
Block a user