mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
fix: block creating oidc users when oidc has not been configured (#14064)
This commit is contained in:
@ -464,6 +464,12 @@ func (api *API) postUser(rw http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
loginType = database.LoginTypePassword
|
loginType = database.LoginTypePassword
|
||||||
case codersdk.LoginTypeOIDC:
|
case codersdk.LoginTypeOIDC:
|
||||||
|
if api.OIDCConfig == nil {
|
||||||
|
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
||||||
|
Message: "You must configure OIDC before creating OIDC users.",
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
loginType = database.LoginTypeOIDC
|
loginType = database.LoginTypeOIDC
|
||||||
case codersdk.LoginTypeGithub:
|
case codersdk.LoginTypeGithub:
|
||||||
loginType = database.LoginTypeGithub
|
loginType = database.LoginTypeGithub
|
||||||
@ -471,6 +477,7 @@ func (api *API) postUser(rw http.ResponseWriter, r *http.Request) {
|
|||||||
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
||||||
Message: fmt.Sprintf("Unsupported login type %q for manually creating new users.", req.UserLoginType),
|
Message: fmt.Sprintf("Unsupported login type %q for manually creating new users.", req.UserLoginType),
|
||||||
})
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user, _, err := api.CreateUser(ctx, api.Database, CreateUserRequest{
|
user, _, err := api.CreateUser(ctx, api.Database, CreateUserRequest{
|
||||||
|
Reference in New Issue
Block a user