mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
feat(codersdk): export name validators (#14550)
* feat(codersdk): export name validators * review
This commit is contained in:
@ -266,7 +266,7 @@ func validOrganizationRoleRequest(ctx context.Context, req codersdk.CustomRoleRe
|
||||
return false
|
||||
}
|
||||
|
||||
if err := httpapi.NameValid(req.Name); err != nil {
|
||||
if err := codersdk.NameValid(req.Name); err != nil {
|
||||
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
||||
Message: "Invalid role name",
|
||||
Detail: err.Error(),
|
||||
|
@ -206,7 +206,7 @@ func (api *API) scimPostUser(rw http.ResponseWriter, r *http.Request) {
|
||||
// The username is a required property in Coder. We make a best-effort
|
||||
// attempt at using what the claims provide, but if that fails we will
|
||||
// generate a random username.
|
||||
usernameValid := httpapi.NameValid(sUser.UserName)
|
||||
usernameValid := codersdk.NameValid(sUser.UserName)
|
||||
if usernameValid != nil {
|
||||
// If no username is provided, we can default to use the email address.
|
||||
// This will be converted in the from function below, so it's safe
|
||||
@ -214,7 +214,7 @@ func (api *API) scimPostUser(rw http.ResponseWriter, r *http.Request) {
|
||||
if sUser.UserName == "" {
|
||||
sUser.UserName = email
|
||||
}
|
||||
sUser.UserName = httpapi.UsernameFrom(sUser.UserName)
|
||||
sUser.UserName = codersdk.UsernameFrom(sUser.UserName)
|
||||
}
|
||||
|
||||
// TODO: This is a temporary solution that does not support multi-org
|
||||
|
Reference in New Issue
Block a user